Versions in this module Expand all Collapse all v0 v0.1.0 Apr 4, 2024 Changes in this version + const DefaultPort + const FlagEphemeral + const FlagSequence + const FlagTTL + const PermAdmin + const PermAll + const PermCreate + const PermDelete + const PermRead + const PermWrite + var ErrAPIError = errors.New("zk: api error") + var ErrAuthFailed = errors.New("zk: client authentication failed") + var ErrBadArguments = errors.New("invalid arguments") + var ErrBadVersion = errors.New("zk: version conflict") + var ErrClosing = errors.New("zk: zookeeper is closing") + var ErrConnectionClosed = errors.New("zk: connection closed") + var ErrInvalidACL = errors.New("zk: invalid ACL specified") + var ErrInvalidPath = errors.New("zk: invalid path") + var ErrNoAuth = errors.New("zk: not authenticated") + var ErrNoChildrenForEphemerals = errors.New("zk: ephemeral nodes may not have children") + var ErrNoNode = errors.New("zk: node does not exist") + var ErrNodeExists = errors.New("zk: node already exists") + var ErrNotEmpty = errors.New("zk: node has children") + var ErrNothing = errors.New("zk: no server responses to process") + var ErrPtrExpected = errors.New("zk: encode/decode expect a non-nil pointer to struct") + var ErrReconfigDisabled = errors.New(...) + var ErrSessionExpired = errors.New("zk: session has been expired by the server") + var ErrSessionMoved = errors.New("zk: session moved to another server, so operation is ignored") + var ErrShortBuffer = errors.New("zk: buffer too small") + var ErrUnhandledFieldType = errors.New("zk: unhandled field type") + var ErrUnknown = errors.New("zk: unknown error") + func FormatServers(servers []string) []string + func ValidatePath(path string, isSequential bool) error + type ACL struct + ID string + Perms int32 + Scheme string + func AuthACL(perms int32) []ACL + func DigestACL(perms int32, user, password string) []ACL + func WorldACL(perms int32) []ACL + type AddAuthResponse struct + Zxid int64 + type CheckVersionRequest PathVersionRequest + type ChildrenOption func(opts *childrenOpts) + func WithChildrenWatch(callback func(ev Event)) ChildrenOption + type ChildrenResponse struct + Children []string + Zxid int64 + type Client struct + func NewClient(servers []string, sessionTimeout time.Duration, options ...Option) (*Client, error) + func (c *Client) AddAuth(scheme string, auth []byte, callback func(resp AddAuthResponse, err error)) + func (c *Client) Children(path string, callback func(resp ChildrenResponse, err error), ...) + func (c *Client) Close() + func (c *Client) Create(path string, data []byte, flags int32, acl []ACL, ...) + func (c *Client) Delete(path string, version int32, callback func(resp DeleteResponse, err error)) + func (c *Client) Exists(path string, callback func(resp ExistsResponse, err error), ...) + func (c *Client) Get(path string, callback func(resp GetResponse, err error), options ...GetOption) + func (c *Client) GetACL(path string, callback func(resp GetACLResponse, err error)) + func (c *Client) Set(path string, data []byte, version int32, ...) + func (c *Client) SetACL(path string, acl []ACL, version int32, ...) + type CreateContainerRequest CreateRequest + type CreateRequest struct + Acl []ACL + Data []byte + Flags int32 + Path string + type CreateResponse struct + Path string + Zxid int64 + type CreateTTLRequest struct + Acl []ACL + Data []byte + Flags int32 + Path string + Ttl int64 + type DeleteRequest PathVersionRequest + type DeleteResponse struct + Zxid int64 + type ErrCode int32 + type Event struct + Path string + State State + Type EventType + type EventType int32 + const EventNodeChildrenChanged + const EventNodeCreated + const EventNodeDataChanged + const EventNodeDeleted + func (t EventType) String() string + type ExistsOption func(opts *existsOpts) + func WithExistsWatch(callback func(ev Event)) ExistsOption + type ExistsResponse struct + Stat Stat + Zxid int64 + type GetACLResponse struct + ACL []ACL + Stat Stat + Zxid int64 + type GetOption func(opts *getOpts) + func WithGetWatch(callback func(ev Event)) GetOption + type GetResponse struct + Data []byte + Stat Stat + Zxid int64 + type Logger interface + Errorf func(format string, args ...any) + Infof func(format string, args ...any) + Warnf func(format string, args ...any) + type Mode uint8 + const ModeFollower + const ModeLeader + const ModeStandalone + const ModeUnknown + func (m Mode) String() string + type NetworkConn interface + SetReadDeadline func(d time.Duration) error + SetWriteDeadline func(d time.Duration) error + func NewTCPConn(conn net.Conn) NetworkConn + type Option func(c *Client) + func WithDialRetryDuration(d time.Duration) Option + func WithDialTimeoutFunc(dialFunc func(addr string, timeout time.Duration) (NetworkConn, error)) Option + func WithLogger(l Logger) Option + func WithReconnectingCallback(callback func(c *Client)) Option + func WithServerSelector(selector ServerSelector) Option + func WithSessionEstablishedCallback(callback func(c *Client)) Option + func WithSessionExpiredCallback(callback func(c *Client)) Option + type PathVersionRequest struct + Path string + Version int32 + type SelectNextOutput struct + RetryStart bool + Server string + type ServerClient struct + Addr string + AvgLatency int32 + Error error + Established time.Time + LastLatency int32 + LastOperation string + LastResponse time.Time + Lcxid int64 + Lzxid int64 + MaxLatency int32 + MinLatency int32 + Queued int64 + Received int64 + Sent int64 + SessionID int64 + Timeout int32 + type ServerClients struct + Clients []*ServerClient + Error error + type ServerListSelector struct + func (s *ServerListSelector) Init(servers []string) + func (s *ServerListSelector) Next() SelectNextOutput + func (s *ServerListSelector) NotifyConnected() + type ServerSelector interface + Init func(servers []string) + Next func() SelectNextOutput + NotifyConnected func() + func NewServerListSelector(seed int64) ServerSelector + type ServerStats struct + AvgLatency float64 + BuildTime time.Time + Connections int64 + Counter int32 + Epoch int32 + Error error + MaxLatency int64 + MinLatency int64 + Mode Mode + NodeCount int64 + Outstanding int64 + Received int64 + Sent int64 + Server string + Version string + type SetACLResponse struct + Stat Stat + Zxid int64 + type SetDataRequest struct + Data []byte + Path string + Version int32 + type SetResponse struct + Stat Stat + Zxid int64 + type Stat struct + Aversion int32 + Ctime int64 + Cversion int32 + Czxid int64 + DataLength int32 + EphemeralOwner int64 + Mtime int64 + Mzxid int64 + NumChildren int32 + Pzxid int64 + Version int32 + type State int32 + const StateAuthFailed + const StateConnected + const StateConnectedReadOnly + const StateConnecting + const StateDisconnected + const StateExpired + const StateHasSession + const StateSaslAuthenticated + const StateUnknown + func (s State) String() string