1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-03 15:22:30 +02:00

34 lines
709 B
Go
Raw Normal View History

package nacos
import (
"context"
2021-10-12 12:55:53 +01:00
"go-micro.dev/v4/registry"
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
)
type addressKey struct{}
type configKey struct{}
// WithAddress sets the nacos address
func WithAddress(addrs []string) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, addressKey{}, addrs)
}
}
// WithClientConfig sets the nacos config
func WithClientConfig(cc constant.ClientConfig) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, configKey{}, cc)
}
}