feat: registry.
This commit is contained in:
@@ -23,49 +23,13 @@ var (
|
||||
_ registry.Discovery = (*Registry)(nil)
|
||||
)
|
||||
|
||||
type options struct {
|
||||
prefix string
|
||||
weight float64
|
||||
cluster string
|
||||
group string
|
||||
kind string
|
||||
}
|
||||
|
||||
// Option is nacos option.
|
||||
type Option func(o *options)
|
||||
|
||||
// WithPrefix with prefix path.
|
||||
func WithPrefix(prefix string) Option {
|
||||
return func(o *options) { o.prefix = prefix }
|
||||
}
|
||||
|
||||
// WithWeight with weight option.
|
||||
func WithWeight(weight float64) Option {
|
||||
return func(o *options) { o.weight = weight }
|
||||
}
|
||||
|
||||
// WithCluster with cluster option.
|
||||
func WithCluster(cluster string) Option {
|
||||
return func(o *options) { o.cluster = cluster }
|
||||
}
|
||||
|
||||
// WithGroup with group option.
|
||||
func WithGroup(group string) Option {
|
||||
return func(o *options) { o.group = group }
|
||||
}
|
||||
|
||||
// WithDefaultKind with default kind option.
|
||||
func WithDefaultKind(kind string) Option {
|
||||
return func(o *options) { o.kind = kind }
|
||||
}
|
||||
|
||||
// Registry is nacos registry.
|
||||
type Registry struct {
|
||||
opts options
|
||||
cli naming_client.INamingClient
|
||||
}
|
||||
|
||||
// New new a nacos registry.
|
||||
// New a nacos registry.
|
||||
func New(cli naming_client.INamingClient, opts ...Option) (r *Registry) {
|
||||
op := options{
|
||||
prefix: "/microservices",
|
||||
|
||||
Reference in New Issue
Block a user