feat: registry.

This commit is contained in:
Bobo
2025-06-02 11:53:18 +08:00
parent b0e91998e1
commit 59c731904a
83 changed files with 7154 additions and 1784 deletions

View File

@@ -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",