Documentation ¶
Overview ¶
Package etcd implements service Registry and Discovery using etcd.
Index ¶
- Constants
- func New(address string, option ...Option) gsvc.Registry
- type Option
- type Registry
- func (r *Registry) Deregister(ctx context.Context, service gsvc.Service) error
- func (r *Registry) Register(ctx context.Context, service gsvc.Service) (gsvc.Service, error)
- func (r *Registry) Search(ctx context.Context, in gsvc.SearchInput) ([]gsvc.Service, error)
- func (r *Registry) Watch(ctx context.Context, key string) (gsvc.Watcher, error)
- type Service
Constants ¶
const ( // DefaultKeepAliveTTL is the default keepalive TTL. DefaultKeepAliveTTL = 10 * time.Second // DefaultDialTimeout is the timeout for failing to establish a connection. DefaultDialTimeout = time.Second * 5 // DefaultAutoSyncInterval is the interval to update endpoints with its latest members. // 0 disables auto-sync. By default auto-sync is disabled. DefaultAutoSyncInterval = time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option struct { Logger glog.ILogger KeepaliveTTL time.Duration // DialTimeout is the timeout for failing to establish a connection. DialTimeout time.Duration // AutoSyncInterval is the interval to update endpoints with its latest members. AutoSyncInterval time.Duration DialOptions []grpc.DialOption }
Option is the option for the etcd registry.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry implements gsvc.Registry interface.
func NewWithClient ¶
NewWithClient creates and returns a new etcd registry with the given client.
func (*Registry) Deregister ¶
Deregister off-lines and removes `service` from the Registry.
func (*Registry) Register ¶
Register registers `service` to Registry. Note that it returns a new Service if it changes the input Service with custom one.
type Service ¶
Service wrapper.
func NewService ¶
NewService creates and returns local Service from gsvc.Service interface object.
func (*Service) GetEndpoints ¶
GetEndpoints returns the Endpoints of service. The Endpoints contain multiple host/port information of service.
func (*Service) GetMetadata ¶
GetMetadata returns the Metadata map of service. The Metadata is key-value pair map specifying extra attributes of a service.