enhanced

package
v0.0.0-...-a660477 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildrenResult

type ChildrenResult struct {
	Path     string
	Stat     *zk.Stat
	Err      error
	Children []string
}

ChildrenResult contains the result of a ChildrenWatch.

type Client

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

Client is an enhanced connection.

func Connect

func Connect(servers []string, sessionTimeout time.Duration) (*Client, error)

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

func (c *Client) BlockUntilConnected(timeout time.Duration) bool

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) Conn

func (c *Client) Conn() *zk.Conn

Conn returns internal zk.Conn.

func (*Client) Create

func (nb *Client) Create(p string) error

Create creates given znode with value set to nil.

func (*Client) CreateValue

func (nb *Client) CreateValue(p string, value []byte) error

CreateValue creates given znode with value.

func (*Client) CreateValueWithParents

func (nb *Client) CreateValueWithParents(p string, value []byte) error

CreateValueWithParents create path with value and its parents created if missing.

func (*Client) CreateWithParents

func (nb *Client) CreateWithParents(p string) error

CreateWithParents create path with its parents created if missing.

func (Client) DelListener

func (w Client) DelListener(listener *ConnectionStateListener)

DelListener deletes a ConnectionStateListener.

func (*Client) Delete

func (nb *Client) Delete(p string, version int32) error

Delete deletes given znode.

func (*Client) DeleteWithChildren

func (nb *Client) DeleteWithChildren(p string) error

DeleteWithChildren deletes given znode with its children if any.

func (*Client) Exist

func (nb *Client) Exist(p string) (bool, *zk.Stat, error)

Exist returns true and stat of given znode if it exists.

func (*Client) Get

func (nb *Client) Get(p string) ([]byte, *zk.Stat, error)

Get fetches value and stat of given znode.

func (*Client) GetChildren

func (nb *Client) GetChildren(p string) ([]string, *zk.Stat, error)

GetChildren fetches children of given path.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected returns true if a session is currently created.

func (*Client) Namespace

func (c *Client) Namespace() string

Namespace returns namespace used for all operation.

func (*Client) Set

func (nb *Client) Set(p string, value []byte, version int32) (*zk.Stat, error)

Set sets the value on given znode.

func (*Client) SetDigestAuth

func (c *Client) SetDigestAuth(auth []byte) error

SetDigestAuth sets auth as digest.

func (*Client) SetNamespace

func (c *Client) SetNamespace(ns string) *Client

SetNamespace sets the namespace used for all operation. NOTE: namespace does not start with /.

func (Client) Start

func (w Client) Start()

Start starts to listener for events.

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

Add adds a Listener.

func (*ConnectionStateListeners) Broadcast

func (l *ConnectionStateListeners) Broadcast(e zk.Event)

Broadcast calls every listener with given event.

func (*ConnectionStateListeners) Del

Del deletes a Listener.

type Conner

type Conner interface {
	Conn() *zk.Conn
}

Conner represents a getter of *zk.Conn.

type DataResult

type DataResult struct {
	Path string
	Stat *zk.Stat
	Err  error
	Data []byte
}

DataResult contains the result of a DataWatch.

type ExistResult

type ExistResult struct {
	Path  string
	Stat  *zk.Stat
	Err   error
	Exist bool
}

ExistResult contains the result of a ExistWatch.

type ListenerContainer

type ListenerContainer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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

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.

Jump to

Keyboard shortcuts

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