Documentation ¶
Overview ¶
@Time : 2019/6/4 16:18 @Author : kenny zhu @File : interface @Software: GoLand @Others:
Package etcdv3 provides an etcd version 3 registry ¶
@Time : 2019/6/4 16:41 @Author : kenny zhu @File : interface @Software: GoLand @Others:
@Time : 2019/6/4 16:21 @Author : kenny zhu @File : options @Software: GoLand @Others:
@Time : 2019/6/4 16:22 @Author : kenny zhu @File : registry @Software: GoLand @Others:
@Time : 2019/6/4 16:43 @Author : kenny zhu @File : watcher @Software: GoLand @Others:
Index ¶
- Variables
- func Deregister(s *Service) error
- func Register(s *Service, opts ...RegisterOption) error
- func String() string
- type Endpoint
- type Node
- type Option
- type Options
- type RegisterOption
- type RegisterOptions
- type Registry
- type Result
- type Service
- type Value
- type WatchOption
- type WatchOptions
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ( // default use et-cdv3.. DefaultRegistry = NewRegistry() // Not found error when GetService is called ErrNotFound = errors.New("not found") // Watcher stopped error when watcher is stopped ErrWatcherStopped = errors.New("watcher stopped") )
Functions ¶
func Register ¶
func Register(s *Service, opts ...RegisterOption) error
Register a service node. Additionally supply options such as TTL.
Types ¶
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
func RegisterTTL ¶
func RegisterTTL(t time.Duration) RegisterOption
type RegisterOptions ¶
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 }
The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}
func NewRegistry ¶
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"` Metadata map[string]string `json:"metadata"` Endpoints []*Endpoint `json:"endpoints"` Nodes []*Node `json:"nodes"` }
func GetService ¶
Retrieve a service. A slice is returned since we separate Name/Version.
func ListServices ¶
List the services. Only returns service names
type WatchOption ¶
type WatchOption func(*WatchOptions)