zkplus

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2019 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = log.Logger(log.DefaultLogger.CreateChild())

DefaultLogger is used by zkplus when no logger is set for the struct

Functions

This section is empty.

Types

type Builder

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

Builder helps users build a ZkPlus connection

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new builder for making ZkPlus connections

func (*Builder) AppendPathPrefix

func (b *Builder) AppendPathPrefix(childPath string) *Builder

AppendPathPrefix to the existing path. Can be chained to create /a/b/c directories

func (*Builder) Build

func (b *Builder) Build() (*ZkPlus, error)

Build a ZkPlus connection, returning an error if the path doesn't make sense

func (*Builder) BuildDirect

func (b *Builder) BuildDirect() (*ZkPlus, <-chan zk.Event, error)

BuildDirect is a helper that looks like the regular zk create function

func (*Builder) Connector

func (b *Builder) Connector(zkConnector ZkConnector) *Builder

Connector sets what we use to create zk connections

func (*Builder) DialZkConnector

func (b *Builder) DialZkConnector(servers []string, sessionTimeout time.Duration, dialer zk.Dialer) *Builder

DialZkConnector sets how zk network connections are created

func (*Builder) Logger

func (b *Builder) Logger(logger log.Logger) *Builder

Logger sets where messages are logged by zkplus

func (*Builder) PathPrefix

func (b *Builder) PathPrefix(pathPrefix string) *Builder

PathPrefix is the prefix any zk operations get

func (*Builder) ZkPlus

func (b *Builder) ZkPlus(zkPlus *ZkPlus) *Builder

ZkPlus copies the config from another connection

type StaticConnector

type StaticConnector struct {
	C  zktest.ZkConnSupported
	Ch <-chan zk.Event
}

A StaticConnector will always return the same connection and chan for every connection request. Usually only needed for testing

func (*StaticConnector) Conn

func (s *StaticConnector) Conn() (zktest.ZkConnSupported, <-chan zk.Event, error)

Conn will just return the constructed connection and event channel

type ZkConnector

type ZkConnector interface {
	Conn() (zktest.ZkConnSupported, <-chan zk.Event, error)
}

ZkConnector tells ZkPlus how to create a zk connection

type ZkConnectorFunc

type ZkConnectorFunc func() (zktest.ZkConnSupported, <-chan zk.Event, error)

ZkConnectorFunc is a helper to wrap a simple function for making Zk connections

func (ZkConnectorFunc) Conn

func (f ZkConnectorFunc) Conn() (zktest.ZkConnSupported, <-chan zk.Event, error)

Conn to a Zk Connection, calling itself to create the connection

type ZkPlus

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

ZkPlus wraps a zookeeper connection to provide namespacing, auto reconnects, and server list changing

func (*ZkPlus) Children

func (z *ZkPlus) Children(path string) ([]string, *zk.Stat, error)

Children gets children of a path

func (*ZkPlus) ChildrenW

func (z *ZkPlus) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error)

ChildrenW is like children but also sets a watch

func (*ZkPlus) Close

func (z *ZkPlus) Close()

Close this zk connection, blocking till the eventLoop() is finished.

func (*ZkPlus) Create

func (z *ZkPlus) Create(path string, data []byte, flags int32, acl []zk.ACL) (string, error)

Create a Zk node

func (*ZkPlus) Delete

func (z *ZkPlus) Delete(path string, version int32) error

Delete a Zk node

func (*ZkPlus) EventChan

func (z *ZkPlus) EventChan() <-chan zk.Event

EventChan that will see zookeeper events whose path is changed to this zk connection's namespace

func (*ZkPlus) Exists

func (z *ZkPlus) Exists(path string) (bool, *zk.Stat, error)

Exists returns true if the path exists

func (*ZkPlus) ExistsW

func (z *ZkPlus) ExistsW(path string) (bool, *zk.Stat, <-chan zk.Event, error)

ExistsW is like Exists but also sets a watch. Note: We DO NOT change paths on the returned channel nor do we reconnect it. Use the global channel instead

func (*ZkPlus) Get

func (z *ZkPlus) Get(path string) ([]byte, *zk.Stat, error)

Get the bytes of a zk path

func (*ZkPlus) GetW

func (z *ZkPlus) GetW(path string) ([]byte, *zk.Stat, <-chan zk.Event, error)

GetW is like Get, but also sets a watch

func (*ZkPlus) Set

func (z *ZkPlus) Set(path string, data []byte, version int32) (*zk.Stat, error)

Set the data of a zk node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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