Documentation ¶
Overview ¶
Package nacos implements service Registry and Discovery using nacos.
Index ¶
- func NewServiceFromInstance(instance []model.Instance) gsvc.Service
- func NewServicesFromInstances(instances []model.Instance) []gsvc.Service
- type Config
- type Registry
- func (reg *Registry) Deregister(ctx context.Context, service gsvc.Service) (err error)
- func (reg *Registry) Register(ctx context.Context, service gsvc.Service) (registered gsvc.Service, err error)
- func (reg *Registry) Search(ctx context.Context, in gsvc.SearchInput) (result []gsvc.Service, err error)
- func (reg *Registry) SetClusterName(clusterName string) *Registry
- func (reg *Registry) SetGroupName(groupName string) *Registry
- func (reg *Registry) Watch(ctx context.Context, key string) (watcher gsvc.Watcher, err error)
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServiceFromInstance ¶
NewServiceFromInstance new one service from instance
Types ¶
type Config ¶
type Config struct { ServerConfigs []constant.ServerConfig `v:"required"` // See constant.ServerConfig ClientConfig *constant.ClientConfig `v:"required"` // See constant.ClientConfig }
Config is the configuration object for nacos client.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is nacos registry.
func New ¶
func New(address string, opts ...constant.ClientOption) (reg *Registry)
New new a registry with address and opts
func NewWithClient ¶
func NewWithClient(client naming_client.INamingClient) *Registry
NewWithClient new the instance with INamingClient
func NewWithConfig ¶
New creates and returns registry with Config.
func (*Registry) Deregister ¶
Deregister off-lines and removes `service` from the Registry.
func (*Registry) Register ¶
func (reg *Registry) Register(ctx context.Context, service gsvc.Service) (registered gsvc.Service, err error)
Register registers `service` to Registry. Note that it returns a new Service if it changes the input Service with custom one.
func (*Registry) Search ¶
func (reg *Registry) Search(ctx context.Context, in gsvc.SearchInput) (result []gsvc.Service, err error)
Search searches and returns services with specified condition.
func (*Registry) SetClusterName ¶
SetClusterName can set the clusterName. The default is 'DEFAULT'
func (*Registry) SetGroupName ¶
SetGroupName can set the groupName. The default is 'DEFAULT_GROUP'
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher used to mange service event such as update.
func (*Watcher) Proceed ¶
Proceed proceeds watch in blocking way. It returns all complete services that watched by `key` if any change.
func (*Watcher) SetCloseFunc ¶
SetCloseFunc set the close callback function