Documentation ¶
Overview ¶
Package registry is an interface for service discovery
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound Not found error when GetService is called ErrNotFound = errors.New("not found") // ErrWatcherStopped Watcher stopped error when watcher is stopped ErrWatcherStopped = errors.New("watcher stopped") )
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { ID string `json:"id"` Address string `json:"address"` Metadata map[string]string `json:"metadata"` }
Node 节点信息
type Options ¶
type Options struct { Addrs []string Timeout time.Duration // Other options for implementations of the interface // can be stored in a context Context context.Context }
Options options
type RegisterOptions ¶
type RegisterOptions struct { TTL time.Duration // Other options for implementations of the interface // can be stored in a context Context context.Context }
RegisterOptions register options
type Registry ¶
type Registry interface { Init(...Option) error Options() Options Register(*Service, ...RegisterOption) error Deregister(*Service) error GetService(string) ([]*Service, error) ListServices() ([]*Service, error) Watch(...WatchOption) (Watcher, error) String() string }
Registry The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}
type Result ¶
Result is returned by a call to Next on the watcher. Actions can be create, update, delete
type Service ¶
type Service struct { Name string `json:"name"` Version string `json:"version"` Nodes []*Node `json:"nodes"` }
Service 微服务对应的所有节点信息
type WatchOptions ¶
type WatchOptions struct { // Specify a service to watch // If blank, the watch is for all services Service string // Other options for implementations of the interface // can be stored in a context Context context.Context }
WatchOptions watch options
Click to show internal directories.
Click to hide internal directories.