Documentation ¶
Index ¶
- type ChildrenResult
- type Client
- func (w Client) AddListener(listener *ConnectionStateListener)
- func (c *Client) BlockUntilConnected(timeout time.Duration) bool
- func (c *Client) Close()
- func (c *Client) Conn() *zk.Conn
- func (nb *Client) Create(p string) error
- func (nb *Client) CreateValue(p string, value []byte) error
- func (nb *Client) CreateValueWithParents(p string, value []byte) error
- func (nb *Client) CreateWithParents(p string) error
- func (w Client) DelListener(listener *ConnectionStateListener)
- func (nb *Client) Delete(p string, version int32) error
- func (nb *Client) DeleteWithChildren(p string) error
- func (nb *Client) Exist(p string) (bool, *zk.Stat, error)
- func (nb *Client) Get(p string) ([]byte, *zk.Stat, error)
- func (nb *Client) GetChildren(p string) ([]string, *zk.Stat, error)
- func (c *Client) IsConnected() bool
- func (c *Client) Namespace() string
- func (nb *Client) Set(p string, value []byte, version int32) (*zk.Stat, error)
- func (c *Client) SetDigestAuth(auth []byte) error
- func (c *Client) SetNamespace(ns string) *Client
- func (w Client) Start()
- func (w *Client) WatchChildren(p string, processResult func(ChildrenResult), processEvent func(zk.Event))
- func (w *Client) WatchData(p string, processResult func(DataResult), processEvent func(zk.Event))
- func (w *Client) WatchExist(p string, processResult func(ExistResult), processEvent func(zk.Event))
- type ConnectionStateListener
- type ConnectionStateListeners
- type Conner
- type DataResult
- type ExistResult
- type ListenerContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChildrenResult ¶
ChildrenResult contains the result of a ChildrenWatch.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an enhanced connection.
func Connect ¶
Connect establishes a new connection to a pool of zookeeper servers. The provided session timeout sets the amount of time for which a session is considered valid after losing connection to a server. Within the session timeout it's possible to reestablish a connection to a different server and keep the same session. This is means any ephemeral nodes and watches are maintained.
func (Client) AddListener ¶
func (w Client) AddListener(listener *ConnectionStateListener)
AddListener adds a ConnectionStateListener.
func (*Client) BlockUntilConnected ¶
BlockUntilConnected blocks until session is created. The returning value indicates whether the session is created.
func (*Client) Close ¶
func (c *Client) Close()
Close closes inner connection then stops all watchers.
func (*Client) CreateValue ¶
CreateValue creates given znode with value.
func (*Client) CreateValueWithParents ¶
CreateValueWithParents create path with value and its parents created if missing.
func (*Client) CreateWithParents ¶
CreateWithParents create path with its parents created if missing.
func (Client) DelListener ¶
func (w Client) DelListener(listener *ConnectionStateListener)
DelListener deletes a ConnectionStateListener.
func (*Client) DeleteWithChildren ¶
DeleteWithChildren deletes given znode with its children if any.
func (*Client) GetChildren ¶
GetChildren fetches children of given path.
func (*Client) IsConnected ¶
IsConnected returns true if a session is currently created.
func (*Client) SetDigestAuth ¶
SetDigestAuth sets auth as digest.
func (*Client) SetNamespace ¶
SetNamespace sets the namespace used for all operation. NOTE: namespace does not start with /.
func (*Client) WatchChildren ¶
func (w *Client) WatchChildren(p string, processResult func(ChildrenResult), processEvent func(zk.Event))
WatchChildren watches children of given path. processResult will be called after watching. processEvent will be called with further event ONCE.
func (*Client) WatchData ¶
func (w *Client) WatchData(p string, processResult func(DataResult), processEvent func(zk.Event))
WatchData watches data of given path. processResult will be called after watching. processEvent will be called with further event ONCE.
func (*Client) WatchExist ¶
func (w *Client) WatchExist(p string, processResult func(ExistResult), processEvent func(zk.Event))
WatchExist watches existence of given path. processResult will be called after watching. processEvent will be called with further event ONCE.
type ConnectionStateListener ¶
type ConnectionStateListener struct {
// contains filtered or unexported fields
}
ConnectionStateListener is a handler of zk.Event.
func NewConnectionStateListener ¶
func NewConnectionStateListener(fn func(zk.Event)) *ConnectionStateListener
NewConnectionStateListener creates ConnectionStateListener from fn.
func (*ConnectionStateListener) Handle ¶
func (l *ConnectionStateListener) Handle(e zk.Event)
Handle calls the function with e.
type ConnectionStateListeners ¶
type ConnectionStateListeners struct {
*ListenerContainer
}
ConnectionStateListeners is a container of ConnectionStateListeners.
func NewConnectionStateListeners ¶
func NewConnectionStateListeners() *ConnectionStateListeners
NewConnectionStateListeners creates empty ConnectionStateListeners.
func (*ConnectionStateListeners) Add ¶
func (l *ConnectionStateListeners) Add(listener *ConnectionStateListener)
Add adds a Listener.
func (*ConnectionStateListeners) Broadcast ¶
func (l *ConnectionStateListeners) Broadcast(e zk.Event)
Broadcast calls every listener with given event.
func (*ConnectionStateListeners) Del ¶
func (l *ConnectionStateListeners) Del(listener *ConnectionStateListener)
Del deletes a Listener.
type DataResult ¶
DataResult contains the result of a DataWatch.
type ExistResult ¶
ExistResult contains the result of a ExistWatch.
type ListenerContainer ¶
ListenerContainer implements a general container of listeners.
func NewListenerContainer ¶
func NewListenerContainer() *ListenerContainer
NewListenerContainer creates empty ListenerContainer.
func (*ListenerContainer) Add ¶
func (l *ListenerContainer) Add(listener interface{})
Add adds a Listener.
func (*ListenerContainer) Clear ¶
func (l *ListenerContainer) Clear() *ListenerContainer
Clear removes all listeners.
func (*ListenerContainer) Count ¶
func (l *ListenerContainer) Count() int
Count returns the number of listeners.
func (*ListenerContainer) Del ¶
func (l *ListenerContainer) Del(listener interface{})
Del deletes the first occurrence of listener.
func (*ListenerContainer) Foreach ¶
func (l *ListenerContainer) Foreach(fn func(interface{}))
Foreach calls every listener with given function.