Documentation
¶
Overview ¶
Package to interface Hailo systems and config with Zookeeper
NOTE: All path parameters should be formated like below. Slashes for the separator and the leading slash are required.
path := "/path/to/my/data"
Index ¶
- Constants
- Variables
- func Children(path string) ([]string, *gozk.Stat, error)
- func ChildrenW(path string) ([]string, *gozk.Stat, <-chan gozk.Event, error)
- func CloseConnection() error
- func Create(path string, data []byte, flags int32, acl []gozk.ACL) (string, error)
- func CreateParents(path string) error
- func CreateProtectedEphemeralSequential(path string, data []byte, acl []gozk.ACL) (string, error)
- func Delete(path string, version int32) error
- func Exists(path string) (bool, *gozk.Stat, error)
- func ExistsW(path string) (bool, *gozk.Stat, <-chan gozk.Event, error)
- func Get(path string) ([]byte, *gozk.Stat, error)
- func GetACL(path string) ([]gozk.ACL, *gozk.Stat, error)
- func GetW(path string) ([]byte, *gozk.Stat, <-chan gozk.Event, error)
- func HealthCheck() healthcheck.Checker
- func MaxConnHealthCheck(maxconns int) healthcheck.Checker
- func Multi(ops gozk.MultiOps) error
- func NewLock(path string, acl []gozk.ACL) gozk.Locker
- func Set(path string, data []byte, version int32) (*gozk.Stat, error)
- func SetACL(path string, acl []gozk.ACL, version int32) (*gozk.Stat, error)
- func State() gozk.State
- func Sync(path string) (string, error)
- func TearDown()
- func WaitForConnect(d time.Duration) error
- type MockLock
- type MockZookeeperClient
- func (c *MockZookeeperClient) Children(path string) ([]string, *gozk.Stat, error)
- func (c *MockZookeeperClient) ChildrenW(path string) ([]string, *gozk.Stat, <-chan gozk.Event, error)
- func (c *MockZookeeperClient) Close()
- func (c *MockZookeeperClient) Create(path string, data []byte, flags int32, acl []gozk.ACL) (string, error)
- func (c *MockZookeeperClient) CreateProtectedEphemeralSequential(path string, data []byte, acl []gozk.ACL) (string, error)
- func (c *MockZookeeperClient) Delete(path string, version int32) error
- func (c *MockZookeeperClient) Exists(path string) (bool, *gozk.Stat, error)
- func (c *MockZookeeperClient) ExistsW(path string) (bool, *gozk.Stat, <-chan gozk.Event, error)
- func (c *MockZookeeperClient) Get(path string) ([]byte, *gozk.Stat, error)
- func (c *MockZookeeperClient) GetACL(path string) ([]gozk.ACL, *gozk.Stat, error)
- func (c *MockZookeeperClient) GetW(path string) ([]byte, *gozk.Stat, <-chan gozk.Event, error)
- func (c *MockZookeeperClient) Multi(ops gozk.MultiOps) error
- func (c *MockZookeeperClient) NewLock(path string, acl []gozk.ACL) gozk.Locker
- func (c *MockZookeeperClient) Reconnect() error
- func (c *MockZookeeperClient) Set(path string, data []byte, version int32) (*gozk.Stat, error)
- func (c *MockZookeeperClient) SetACL(path string, acl []gozk.ACL, version int32) (*gozk.Stat, error)
- func (c *MockZookeeperClient) State() gozk.State
- func (c *MockZookeeperClient) Sync(path string) (string, error)
- func (c *MockZookeeperClient) UpdateAddrs(addrs []string) error
- type ZookeeperClient
Constants ¶
const ( HealthCheckId = "com.hailocab.service.zookeeper" MaxConnCheckId = "com.hailocab.service.zookeeper.maxconns" )
Variables ¶
var ( // The connection function used when creating a new ZK connection. Replace this with a mock function during tests // that test ZooKeeper integration Connector func(servers []string, recvTimeout time.Duration) (ZookeeperClient, <-chan gozk.Event, error) = DefaultConnector )
Functions ¶
func CloseConnection ¶
func CloseConnection() error
CloseConnection closes the underlying network connection to zookeeper This will trigger both the send and recv loops to exit and requests to flush and then we will automatically attempt to reconnect
Needless to say, this is the nuclear option, and should only be used as a part of higher level constructs in the event of a near fatal error
func CreateParents ¶
CreateParents creates any parent nodes for the given path if required. If all the parent nodes already exist then no error is returned.
func MaxConnHealthCheck ¶
func MaxConnHealthCheck(maxconns int) healthcheck.Checker
MaxConnHealthCheck asserts that the total number of established connections to all zookeeper nodes falls below a given max threshold.
func TearDown ¶
func TearDown()
Close and remove the connection, WITHOUT attempting to automatically reconnect
func WaitForConnect ¶
WaitForConnect will wait until we are connected to ZK successfully for duration N
Types ¶
type MockLock ¶
func (*MockLock) SetTimeout ¶
type MockZookeeperClient ¶
Implements the ZookeeperClient interface
var ActiveMockZookeeperClient *MockZookeeperClient = nil
This must be set to an instance of MockZookeeperClient before tests begin. MockConnector will always return this pointer
func (*MockZookeeperClient) Close ¶
func (c *MockZookeeperClient) Close()
func (*MockZookeeperClient) CreateProtectedEphemeralSequential ¶
func (*MockZookeeperClient) Delete ¶
func (c *MockZookeeperClient) Delete(path string, version int32) error
func (*MockZookeeperClient) Reconnect ¶
func (c *MockZookeeperClient) Reconnect() error
func (*MockZookeeperClient) State ¶
func (c *MockZookeeperClient) State() gozk.State
func (*MockZookeeperClient) UpdateAddrs ¶
func (c *MockZookeeperClient) UpdateAddrs(addrs []string) error
type ZookeeperClient ¶
type ZookeeperClient interface { Children(path string) ([]string, *gozk.Stat, error) ChildrenW(path string) ([]string, *gozk.Stat, <-chan gozk.Event, error) Close() Create(path string, data []byte, flags int32, acl []gozk.ACL) (string, error) CreateProtectedEphemeralSequential(path string, data []byte, acl []gozk.ACL) (string, error) Delete(path string, version int32) error Exists(path string) (bool, *gozk.Stat, error) ExistsW(path string) (bool, *gozk.Stat, <-chan gozk.Event, error) Get(path string) ([]byte, *gozk.Stat, error) GetACL(path string) ([]gozk.ACL, *gozk.Stat, error) GetW(path string) ([]byte, *gozk.Stat, <-chan gozk.Event, error) Multi(ops gozk.MultiOps) error Reconnect() error Set(path string, data []byte, version int32) (*gozk.Stat, error) SetACL(path string, acl []gozk.ACL, version int32) (*gozk.Stat, error) State() gozk.State Sync(path string) (string, error) UpdateAddrs(addrs []string) error NewLock(path string, acl []gozk.ACL) gozk.Locker }
func DefaultConnector ¶
func DefaultConnector(servers []string, recvTimeout time.Duration) (ZookeeperClient, <-chan gozk.Event, error)
The default connection function used; replace the Connector value with this when you finish testing (if you mocked ZooKeeper)
func MockConnector ¶
func MockConnector(servers []string, recvTimeout time.Duration) (ZookeeperClient, <-chan gozk.Event, error)
Connector which returns a MockZooKeeperClient. To use a ZK mock during testing, replace zookeeper.Connector with this function (and be sure to set it back to zookeeper.DefaultConnector when the test exits [via a deferred call])