Documentation
¶
Index ¶
- Variables
- func EnsureZkFatjar()
- type Connection
- func (c *Connection) Children(path string) (children []string, err error)
- func (c *Connection) ChildrenW(path string) (children []string, event <-chan client.Event, err error)
- func (c *Connection) Close()
- func (c *Connection) Create(path string, node client.Node) error
- func (c *Connection) CreateDir(path string) error
- func (c *Connection) CreateEphemeral(path string, node client.Node) (string, error)
- func (c *Connection) Delete(path string) error
- func (c *Connection) Exists(path string) (bool, error)
- func (c *Connection) Get(path string, node client.Node) (err error)
- func (c *Connection) GetW(path string, node client.Node) (event <-chan client.Event, err error)
- func (c *Connection) ID() int
- func (c *Connection) NewLeader(path string, node client.Node) client.Leader
- func (c *Connection) NewLock(path string) client.Lock
- func (c *Connection) Set(path string, node client.Node) error
- func (c *Connection) SetID(id int)
- func (c *Connection) SetOnClose(f func(int))
- type DSN
- type Driver
- type Leader
- type Lock
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDeadlock is returned when a lock is aquired twice on the same object. ErrDeadlock = errors.New("zk: trying to acquire a lock twice") // ErrNotLocked is returned when a caller attempts to release a lock that // has not been aquired ErrNotLocked = errors.New("zk: not locked") // ErrNoLeaderFound is returned when a leader has not been elected ErrNoLeaderFound = errors.New("zk: no leader found") )
Functions ¶
func EnsureZkFatjar ¶
func EnsureZkFatjar()
EnsureZkFatjar downloads the zookeeper binaries for use in unit tests
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a Zookeeper based implementation of client.Connection.
func (*Connection) Children ¶
func (c *Connection) Children(path string) (children []string, err error)
Children returns the children of the node at the given path.
func (*Connection) ChildrenW ¶
func (c *Connection) ChildrenW(path string) (children []string, event <-chan client.Event, err error)
ChildrenW returns the children of the node at the give path and a channel of events that will yield the next event at that node.
func (*Connection) Close ¶
func (c *Connection) Close()
Close the zk connection. Calling close() twice will result in a panic.
func (*Connection) Create ¶
func (c *Connection) Create(path string, node client.Node) error
Create places data at the node at the given path.
func (*Connection) CreateDir ¶
func (c *Connection) CreateDir(path string) error
CreateDir creates an empty node at the given path.
func (*Connection) CreateEphemeral ¶
func (*Connection) Delete ¶
func (c *Connection) Delete(path string) error
Delete will delete all nodes at the given path or any subpath
func (*Connection) Exists ¶
func (c *Connection) Exists(path string) (bool, error)
Exists checks if a node exists at the given path.
func (*Connection) Get ¶
func (c *Connection) Get(path string, node client.Node) (err error)
Get returns the node at the given path.
func (*Connection) GetW ¶
GetW gets the node at the given path and return a channel to watch for events on that node.
func (*Connection) NewLeader ¶
NewLeader returns a managed leader object at the given path bound to the current connection.
func (*Connection) NewLock ¶
func (c *Connection) NewLock(path string) client.Lock
NewLock returns a managed lock object at the given path bound to the current connection.
func (*Connection) Set ¶
func (c *Connection) Set(path string, node client.Node) error
Set serializes the given node and places it at the given path.
func (*Connection) SetOnClose ¶
func (c *Connection) SetOnClose(f func(int))
SetOnClose sets the callback f to be called when Close is called on c.
type DSN ¶
DSN is a Zookeeper specific struct used for connections. It can be serialized.
type Driver ¶
type Driver struct{}
Driver implements a Zookeeper based client.Driver interface
func (*Driver) GetConnection ¶
func (driver *Driver) GetConnection(dsn, basePath string) (client.Connection, error)
GetConnection returns a Zookeeper connection given the dsn. The caller is responsible for closing the returned connection.
type Leader ¶
type Leader struct {
// contains filtered or unexported fields
}
Leader is an object to facilitate creating an election in zookeeper.
func (*Leader) Current ¶
Current returns the currect elected leader and deserializes it in to node. It will return ErrNoLeaderFound if no leader has been elected.
func (*Leader) ReleaseLead ¶
ReleaseLead release the current leader role. It will return ErrNotLocked if the current object is not locked.