Documentation ¶
Index ¶
- Constants
- type Driver
- type Zdriver
- func (d *Zdriver) Close()
- func (d *Zdriver) Connect(url string) error
- func (d *Zdriver) CreateNode(path string, data []byte) error
- func (d *Zdriver) DeleteNode(path string) error
- func (d *Zdriver) GetConnection() *zk.Conn
- func (d *Zdriver) GetData(path string) ([]byte, error)
- func (d *Zdriver) LockEntity(entity string) (string, bool)
- func (d *Zdriver) ReleaseEntity(path string)
- func (d *Zdriver) WatchForNode(path string) (<-chan zk.Event, error)
Constants ¶
const ( // NodeCreated represents the creation of a znode NodeCreated = zk.EventNodeCreated )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface { Connect(url string) error GetConnection() *zk.Conn CreateNode(path string, data []byte) error DeleteNode(path string) error WatchForNode(path string) (<-chan zk.Event, error) LockEntity(name string) (string, bool) ReleaseEntity(lock string) GetData(path string) ([]byte, error) Close() }
Driver is an interface that abstracts zookeeper calls This is a simple interface that allows for the creation/deletion of nodes Also we can watch for the creation of a node
type Zdriver ¶
type Zdriver struct {
// contains filtered or unexported fields
}
Zdriver is a simple implementation of the Driver interface This allows us to create and delete nodes, and create watches
func (*Zdriver) CreateNode ¶
CreateNode create a znode along a path
func (*Zdriver) DeleteNode ¶
DeleteNode deletes the znode at the given path
func (*Zdriver) GetConnection ¶
GetConnection returns a connection to the same instance of zookeeper the driver is connected to
func (*Zdriver) LockEntity ¶
LockEntity Locks a given entity, preventing other drivers from modifying it Returns the path to the lock and whether we own it or not This uses the locking scheme given in the official zookeeper recipes & solutions Source: http://zookeeper.apache.org/doc/r3.1.2/recipes.html The only change here is that we don't want to spin waiting for the lock
func (*Zdriver) ReleaseEntity ¶
ReleaseEntity releases the entity by deleting the znode that represents the lock