zkcli

package
v0.0.0-...-5157df0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//zk session的超时时间,在此时间内,session可以自动保活
	//如果在此时间内,与特定server的连接断开,自动尝试重连其他服务器
	//重连成功之后,临时节点和watch依然有效
	DefaultConnectTimeout = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

func Connect

func Connect(zkAddr string) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Conn

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

func (*Conn) Create

func (c *Conn) Create(path string, data []byte) error

func (*Conn) CreateEphemeral

func (c *Conn) CreateEphemeral(path string, data []byte) error

func (*Conn) CreateSequence

func (c *Conn) CreateSequence(path string, data []byte) (string, error)

func (*Conn) Delete

func (c *Conn) Delete(path string) error

func (*Conn) Exists

func (c *Conn) Exists(path string) (bool, error)

func (*Conn) Get

func (c *Conn) Get(path string) ([]byte, error)

func (*Conn) GetChildren

func (c *Conn) GetChildren(path string) (map[string][]byte, error)

func (*Conn) MakeDirP

func (c *Conn) MakeDirP(dir string) error

依次创建各级目录,类似unix系统 mkdir -p

func (*Conn) SetConn

func (c *Conn) SetConn(conn *zk.Conn)

func (*Conn) Watch

func (c *Conn) Watch(path string, cb FuncWatchCallback, stopCh chan struct{}) error

func (*Conn) WatchChildren

func (c *Conn) WatchChildren(path string, cb FuncWatchChildrenCallback, stopCh chan struct{}) error

func (*Conn) WatchDir

func (c *Conn) WatchDir(path string, events chan *EventDataChild, exit chan struct{})

watch一个dir的子节点,关注节点的增删

func (*Conn) WatchNode

func (c *Conn) WatchNode(path string, events chan *EventDataNode, exit chan struct{})

func (*Conn) Write

func (c *Conn) Write(path string, data []byte) error

func (*Conn) WriteEphemeral

func (c *Conn) WriteEphemeral(path string, data []byte) error

type EventDataChild

type EventDataChild struct {
	Closed bool
	Err    error
	Adds   map[string]string //新增path/value
	Dels   []string          //删除path
}

type EventDataNode

type EventDataNode struct {
	Closed bool
	Err    error
	Path   string
	Value  string
	OldVal string
}

type FuncWatchCallback

type FuncWatchCallback func(path string, data []byte, err error)

回调:监视节点变化

type FuncWatchChildrenCallback

type FuncWatchChildrenCallback func(path string, children []string, err error)

回调:监视子节点改变

Jump to

Keyboard shortcuts

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