add registry base interface, mdns, noop implementations, add resolver, client

This commit is contained in:
2020-11-08 19:28:33 +01:00
parent 87b947cea3
commit 9f5f03b862
29 changed files with 4341 additions and 41 deletions

63
client/options.go Normal file
View File

@ -0,0 +1,63 @@
package client
import (
"crypto/tls"
"gitlab.bertha.cloud/partitio/lab/grpc/registry"
)
type Options interface {
Version() string
Registry() registry.Registry
TLSConfig() *tls.Config
}
type Option func(*options)
func WithRegistry(registry registry.Registry) Option {
return func(o *options) {
o.registry = registry
}
}
func WithVersion(version string) Option {
return func(o *options) {
o.version = version
}
}
func WithTLSConfig(conf *tls.Config) Option {
return func(o *options) {
o.tlsConfig = conf
}
}
func WithSecure(s bool) Option {
return func(o *options) {
o.secure = s
}
}
type options struct {
registry registry.Registry
version string
tlsConfig *tls.Config
secure bool
}
func (o *options) Version() string {
return o.version
}
func (o *options) Registry() registry.Registry {
return o.registry
}
func (o *options) TLSConfig() *tls.Config {
return o.tlsConfig
}
func (o *options) Secure() bool {
return o.secure
}