mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-06-22 09:12:28 +00:00
add registry base interface, mdns, noop implementations, add resolver, client
This commit is contained in:
63
client/options.go
Normal file
63
client/options.go
Normal 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user