zk

package
v0.0.0-...-3bf07d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var (
	DefaultACL            = zk.WorldACL(zk.PermAll)
	ErrInvalidCredentials = errors.New("invalid credentials provided")
	ErrClientClosed       = errors.New("client service closed")
)

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
	// Stop should properly shutdown the client implementation
	Stop()
}

Client is a wrapper around a lower level ZooKeeper client implementation.

func NewClient

func NewClient(servers []string, logger log.Logger, options ...Option) (Client, error)

NewClient returns a ZooKeeper client with a connection to the server cluster. It will return an error if the server cluster cannot be resolved.

type Option

type Option func(*clientConfig) error

Option functions enable friendly APIs.

func ACL

func ACL(acl []zk.ACL) Option

ACL returns an Option specifying a non-default ACL for creating parent nodes.

func ConnectTimeout

func ConnectTimeout(t time.Duration) Option

ConnectTimeout returns an Option specifying a non-default connection timeout when we try to establish a connection to a ZooKeeper server.

func Credentials

func Credentials(user, pass string) Option

Credentials returns an Option specifying a user/password combination which the client will use to authenticate itself with.

func EventHandler

func EventHandler(handler func(zk.Event)) Option

EventHandler returns an Option specifying a callback function to handle incoming zk.Event payloads (ZooKeeper connection events).

func Payload

func Payload(payload [][]byte) Option

Payload returns an Option specifying non-default data values for each znode created by CreateParentNodes.

func SessionTimeout

func SessionTimeout(t time.Duration) Option

SessionTimeout returns an Option specifying a non-default session timeout.

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

Publisher yield endpoints stored in a certain ZooKeeper path. Any kind of change in that path is watched and will update the Publisher endpoints.

func NewPublisher

func NewPublisher(c Client, path string, f loadbalancer.Factory, logger log.Logger) (*Publisher, error)

NewPublisher returns a ZooKeeper publisher. ZooKeeper will start watching the given path for changes and update the Publisher endpoints.

func (*Publisher) Endpoints

func (p *Publisher) Endpoints() ([]endpoint.Endpoint, error)

Endpoints implements the Publisher interface.

func (*Publisher) Stop

func (p *Publisher) Stop()

Stop terminates the Publisher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL