zookeeper

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilZkClientConn no conn error
	ErrNilZkClientConn = errors.New("zookeeper Client{conn} is nil")
	// ErrNilChildren no children error
	ErrNilChildren = errors.Errorf("has none children")
	// ErrNilNode no node error
	ErrNilNode = errors.Errorf("node does not exist")
)

Functions

func StateToString

func StateToString(state zk.State) string

StateToString will transfer zk state to string

Types

type Option

type Option func(*Options)

Option defines the function to load the options

func WithZkName

func WithZkName(name string) Option

WithZkName sets zk client name

type Options

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

Options defines the client option.

type ZooKeeperClient

type ZooKeeperClient struct {
	ZkAddrs      []string
	sync.RWMutex // for conn

	Timeout time.Duration

	Wait sync.WaitGroup
	// contains filtered or unexported fields
}

ZooKeeperClient represents zookeeper client Configuration

func NewZooKeeperClient

func NewZooKeeperClient(name string, zkAddrs []string, timeout time.Duration) (*ZooKeeperClient, <-chan zk.Event, error)

func (*ZooKeeperClient) Destroy

func (z *ZooKeeperClient) Destroy()

func (*ZooKeeperClient) ExistW

func (z *ZooKeeperClient) ExistW(zkPath string) (<-chan zk.Event, error)

ExistW is a wrapper to the zk connection conn.ExistsW

func (*ZooKeeperClient) GetChildren

func (z *ZooKeeperClient) GetChildren(path string) ([]string, error)

GetChildren gets children by @path

func (*ZooKeeperClient) GetChildrenW

func (z *ZooKeeperClient) GetChildrenW(path string) ([]string, <-chan zk.Event, error)

GetChildrenW gets children watch by @path

func (*ZooKeeperClient) GetConnState

func (z *ZooKeeperClient) GetConnState() zk.State

func (*ZooKeeperClient) GetContent

func (z *ZooKeeperClient) GetContent(path string) ([]byte, error)

GetContent gets content by @path

func (*ZooKeeperClient) HandleZkEvent

func (z *ZooKeeperClient) HandleZkEvent(s <-chan zk.Event)

HandleZkEvent handles zookeeper events

func (*ZooKeeperClient) RegisterHandler

func (z *ZooKeeperClient) RegisterHandler(event <-chan zk.Event)

Jump to

Keyboard shortcuts

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