Documentation
¶
Index ¶
- Variables
- type EventType
- type Logger
- type Option
- type Registration
- type Registry
- func (rr *Registry) Address() string
- func (rr *Registry) Deregister(c context.Context, key string) error
- func (rr *Registry) FindRegistration(c context.Context, key string) (*Registration, error)
- func (rr *Registry) FindRegistrations(c context.Context, prefix string) ([]*Registration, error)
- func (rr *Registry) Register(c context.Context, key string, options ...Option) error
- func (rr *Registry) Registry() string
- func (rr *Registry) Start(addr net.Addr) (<-chan error, error)
- func (rr *Registry) Stop() error
- func (rr *Registry) Watch(c context.Context, prefix string) ([]*Registration, <-chan *WatchEvent, error)
- type WatchEvent
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotOwner = errors.New("registry: not owner") ErrNotStarted = errors.New("registry: not started") ErrUnknownKey = errors.New("registry: unknown key") ErrNilEtcd = errors.New("registry: nil etcd") ErrAlreadyRegistered = errors.New("registry: already registered") ErrFailedRegistration = errors.New("registry: failed registration") ErrFailedDeregistration = errors.New("registry: failed deregistration") ErrLeaseDurationTooShort = errors.New("registry: lease duration too short") ErrUnknownNetAddressType = errors.New("registry: unknown net address type") ErrWatchClosedUnexpectedly = errors.New("registry: watch closed unexpectedly") ErrUnspecifiedNetAddressIP = errors.New("registry: unspecified net address ip") ErrKeepAliveClosedUnexpectedly = errors.New("registry: keep alive closed unexpectedly") )
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
Printf(string, ...interface{})
}
Logger hides the logging function Printf behind a simple interface so libraries such as logrus can be used. Copied from package grid to avoid interndependencies.
type Option ¶
type Option int
const ( // OpAllowReentrantRegistration will cause a registration // to the same key to succeed if it is requested by the // same registry, ie: host, address, process. OpAllowReentrantRegistration Option = 0 )
type Registration ¶
type Registration struct { Key string `json:"key"` Address string `json:"address"` Registry string `json:"registry"` }
Registration information.
func (*Registration) String ¶
func (r *Registration) String() string
String descritpion of registration.
type Registry ¶
type Registry struct { Logger Logger Timeout time.Duration LeaseDuration time.Duration // contains filtered or unexported fields }
Registry for discovery.
func (*Registry) Deregister ¶
Deregister under the given key.
func (*Registry) FindRegistration ¶
FindRegistration associated with the given key.
func (*Registry) FindRegistrations ¶
FindRegistrations associated with the prefix.
func (*Registry) Register ¶
Register under the given key. A registration can happen only once, and registering more than once will return an error. Hence, registration can be used for mutual-exclusion.
func (*Registry) Registry ¶
Registry name, which is a human readable all ASCII transformation of the network address.
func (*Registry) Watch ¶
func (rr *Registry) Watch(c context.Context, prefix string) ([]*Registration, <-chan *WatchEvent, error)
Watch a prefix in the registry.
type WatchEvent ¶
type WatchEvent struct { Key string Reg *Registration Type EventType Error error }
WatchEvent triggred by a change in the registry.
func (*WatchEvent) String ¶
func (we *WatchEvent) String() string
String representation of the watch event.