zookeeper

package
v1.5.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 8 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")
	ErrStatIsNil       = errors.New("Stat of the node is nil")
)

Functions

func WithZkTimeOut

func WithZkTimeOut(t time.Duration) zkClientOption

WithZkTimeOut sets zk Client timeout

Types

type Client

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

Client represents zookeeper Client Configuration

func NewClient

func NewClient(name string, zkAddrs []string, share bool, opts ...zkClientOption) (*Client, error)

NewClient will create a Client

func (*Client) Close

func (c *Client) Close()

func (*Client) ConnValid

func (c *Client) ConnValid() bool

ConnValid validates zookeeper connection

func (*Client) Create

func (c *Client) Create(basePath string) error

Create will create the node recursively, which means that if the parent node is absent, it will create parent node first. And the value for the basePath is ""

func (*Client) CreateTempWithValue

func (c *Client) CreateTempWithValue(basePath string, value []byte) error

CreateTempWithValue will create the node recursively, which means that if the parent node is absent, it will create parent node first,and set value in last child path If the path exist, it will update data

func (*Client) CreateWithValue

func (c *Client) CreateWithValue(basePath string, value []byte) error

CreateWithValue will create the node recursively, which means that if the parent node is absent, it will create parent node first. basePath should start with "/"

func (*Client) Delete

func (c *Client) Delete(basePath string) error

Delete will delete basePath

func (*Client) ExistW

func (c *Client) ExistW(zkPath string) (<-chan zk.Event, error)

ExistW to judge watch whether it exists or not by @zkPath

func (*Client) GetChildren

func (c *Client) GetChildren(path string) ([]string, error)

GetChildren gets children by @path

func (*Client) GetChildrenW

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

GetChildrenW gets children watch by @path

func (*Client) GetContent

func (c *Client) GetContent(zkPath string) ([]byte, *zk.Stat, error)

GetContent gets content by @zkPath

func (*Client) GetEventHandler

func (c *Client) GetEventHandler() EventHandler

GetEventHandler gets zookeeper event handler

func (*Client) Reconnect

func (c *Client) Reconnect() <-chan struct{}

Reconnect gets zookeeper reconnect event

func (*Client) RegisterEvent

func (c *Client) RegisterEvent(zkPath string, event chan zk.Event)

RegisterEvent registers zookeeper events

func (*Client) RegisterTemp

func (c *Client) RegisterTemp(basePath string, node string) (string, error)

RegisterTemp registers temporary node by @basePath and @node

func (*Client) RegisterTempSeq

func (c *Client) RegisterTempSeq(basePath string, data []byte) (string, error)

RegisterTempSeq register temporary sequence node by @basePath and @data

func (*Client) SetContent

func (c *Client) SetContent(zkPath string, content []byte, version int32) (*zk.Stat, error)

SetContent set content of zkPath

func (*Client) UnregisterEvent

func (c *Client) UnregisterEvent(zkPath string, event chan zk.Event)

UnregisterEvent unregisters zookeeper events

type DefaultHandler

type DefaultHandler struct{}

DefaultHandler is default handler for zk event

func (*DefaultHandler) HandleEvent

func (d *DefaultHandler) HandleEvent(z *Client)

HandleEvent handles zookeeper events nolint

type EventHandler

type EventHandler interface {
	HandleEvent(z *Client)
}

EventHandler interface

type Option

type Option func(*options)

Option will define a function of handling Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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