Documentation ¶
Index ¶
Constants ¶
const ( // DefaultConnectTimeout is the default timeout to establish a connection to // a ZooKeeper node. DefaultConnectTimeout = 2 * time.Second // DefaultSessionTimeout is the default timeout to keep the current // ZooKeeper session alive during a temporary disconnect. DefaultSessionTimeout = 5 * time.Second )
Variables ¶
var ( DefaultACL = zk.WorldACL(zk.PermAll) ErrInvalidCredentials = errors.New("invalid credentials provided") ErrClientClosed = errors.New("client service closed") ErrNotRegistered = errors.New("not registered") ErrNodeNotFound = errors.New("node not found") )
DefaultACL is the default ACL to use for creating znodes.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetEntries should query the provided path in ZooKeeper, place a watch on // it and retrieve data from its current child nodes. GetEntries(path string) ([]string, <-chan zk.Event, error) // CreateParentNodes should try to create the path in case it does not exist // yet on ZooKeeper. CreateParentNodes(path string) error // Register a service with ZooKeeper. Register(s *Service) error // Deregister a service with ZooKeeper. Deregister(s *Service) error // Stop should properly shutdown the client implementation Stop() }
Client is a wrapper around a lower level ZooKeeper client implementation.
type Option ¶
type Option func(*clientConfig) error
Option functions enable friendly APIs.
func ConnectTimeout ¶
ConnectTimeout returns an Option specifying a non-default connection timeout when we try to establish a connection to a ZooKeeper server.
func Credentials ¶
Credentials returns an Option specifying a user/password combination which the client will use to authenticate itself with.
func EventHandler ¶
EventHandler returns an Option specifying a callback function to handle incoming zk.Event payloads (ZooKeeper connection events).
func Payload ¶
Payload returns an Option specifying non-default data values for each znode created by CreateParentNodes.
func SessionTimeout ¶
SessionTimeout returns an Option specifying a non-default session timeout.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar registers service instance liveness information to ZooKeeper.
func NewRegistrar ¶
NewRegistrar returns a ZooKeeper Registrar acting on the provided catalog registration.
func (*Registrar) Deregister ¶
func (r *Registrar) Deregister()
Deregister implements sd.Registrar interface.
type Service ¶
type Service struct { Path string // discovery namespace, example: /myorganization/myplatform/ Name string // service name, example: addscv Data []byte // instance data to store for discovery, example: 10.0.2.10:80 // contains filtered or unexported fields }
Service holds the root path, service name and instance identifying data you want to publish to ZooKeeper.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber yield endpoints stored in a certain ZooKeeper path. Any kind of change in that path is watched and will update the Subscriber endpoints.
func NewSubscriber ¶
func NewSubscriber(c Client, path string, factory sd.Factory, logger log.Logger) (*Subscriber, error)
NewSubscriber returns a ZooKeeper subscriber. ZooKeeper will start watching the given path for changes and update the Subscriber endpoints.