Documentation
¶
Overview ¶
zkclient is a client of zookeeper. support features: - auto reconnect - set/get/delete value - support string/json codec, and you can implement your own - real-time synchronize data from zookeeper to memory
Index ¶
- func StateAlive(state zk.State) bool
- type AlarmTrigger
- type Client
- func (cli *Client) AppendDeadWatcher(watcher *Watcher)
- func (cli *Client) Close()
- func (cli *Client) Conn() *zk.Conn
- func (cli *Client) ConnAlive() bool
- func (cli *Client) Connecting() bool
- func (cli *Client) Delete(path string) error
- func (cli *Client) EnsurePath(path string) error
- func (cli *Client) Get(path string, codec Codec, typ reflect.Type) (interface{}, error)
- func (cli *Client) NewWatcher(path string, handler EventHandler) (*Watcher, error)
- func (cli *Client) Reconnect() error
- func (cli *Client) SetAlarmTrigger(f AlarmTrigger)
- func (cli *Client) SetJSON(path string, obj interface{}) error
- func (cli *Client) SetJSONMapValue(path, key string, obj interface{}) error
- func (cli *Client) SetMapValue(path, key string, obj interface{}, codec Codec) error
- func (cli *Client) SetPackValue(path string, pack *PackValue) error
- func (cli *Client) SetRawValue(path string, bytes []byte) error
- func (cli *Client) SetString(path, s string) error
- func (cli *Client) SetStringMapValue(path, key, s string) error
- func (cli *Client) SetValue(path string, obj interface{}, codec Codec) error
- func (cli *Client) Sync(path string, obj interface{}, codec Codec) error
- func (cli *Client) SyncJSON(path string, obj interface{}) error
- func (cli *Client) SyncJSONMap(path string, obj interface{}) error
- func (cli *Client) SyncMap(path string, m interface{}, valueCodec Codec, callback EventCallback, ...) error
- func (cli *Client) SyncString(path, s string) error
- func (cli *Client) SyncStringMap(path string, m map[string]string) error
- type Codec
- type EventCallback
- type EventHandler
- type JSONCodec
- type PackMap
- type PackValue
- type StringCodec
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client for zookeeper
func (*Client) AppendDeadWatcher ¶
AppendDeadWatcher add dead watcher, wait to watch again
func (*Client) Close ¶
func (cli *Client) Close()
Close client, NOT use Client which already calling Close()
func (*Client) EnsurePath ¶
EnsurePath check or create target path
func (*Client) NewWatcher ¶
func (cli *Client) NewWatcher(path string, handler EventHandler) (*Watcher, error)
NewWatcher create new watcher
func (*Client) SetAlarmTrigger ¶
func (cli *Client) SetAlarmTrigger(f AlarmTrigger)
SetAlarmTrigger set zookeeper alarm function
func (*Client) SetJSONMapValue ¶
SetJSONMapValue in zookeeper
func (*Client) SetMapValue ¶
SetMapValue set map value in zookeeper
func (*Client) SetPackValue ¶
SetPackValue set pack value in zookeeper
func (*Client) SetRawValue ¶
SetRawValue set raw value in zookeeper
func (*Client) SetStringMapValue ¶
SetStringMapValue in zookeeper
func (*Client) SyncJSONMap ¶
SyncJSONMap config
type Codec ¶
type Codec interface {
Encode(obj interface{}) ([]byte, error)
Decode(data []byte, typ reflect.Type) (reflect.Value, error)
}
Codec for data
type EventHandler ¶
EventHandler zookeeper event handler
type JSONCodec ¶
type JSONCodec struct{}
JSONCodec struct
type PackValue ¶
type PackValue struct {
// contains filtered or unexported fields
}
func PackString ¶
type StringCodec ¶
type StringCodec struct {
}
func (*StringCodec) Encode ¶
func (c *StringCodec) Encode(obj interface{}) ([]byte, error)