zk

package
v0.0.0-...-21d6f6e Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateUnknown           = zk.StateUnknown
	StateDisconnected      = zk.StateDisconnected
	StateConnecting        = zk.StateConnecting
	StateAuthFailed        = zk.StateAuthFailed
	StateConnectedReadOnly = zk.StateConnectedReadOnly
	StateSaslAuthenticated = zk.StateSaslAuthenticated
	StateExpired           = zk.StateExpired
	StateConnected         = zk.StateConnected
	StateHasSession        = zk.StateHasSession

	EventNodeCreated         = zk.EventNodeCreated
	EventNodeDataChanged     = zk.EventNodeDataChanged
	EventNodeDeleted         = zk.EventNodeDeleted
	EventNodeChildrenChanged = zk.EventNodeChildrenChanged

	// Default Zk timeout
	DefaultTimeout = 1 * time.Hour

	// Defaults to localhost at port 2181.
	DefaultZkHosts = "localhost:2181"

	// Environment variable to use when hosts are not specified explicitly.
	EnvZkHosts = "ZK_HOSTS"
)
View Source
const (
	TimeoutContextKey timeoutContextKey = 1
)

Variables

View Source
var (
	ErrNotConnected            = errors.New("zk-not-initialized")
	ErrConflict                = errors.New("error-conflict")
	ErrNotExist                = zk.ErrNoNode
	ErrConnectionClosed        = zk.ErrConnectionClosed
	ErrUnknown                 = zk.ErrUnknown
	ErrAPIError                = zk.ErrAPIError
	ErrNoAuth                  = zk.ErrNoAuth
	ErrBadVersion              = zk.ErrBadVersion
	ErrNoChildrenForEphemerals = zk.ErrNoChildrenForEphemerals
	ErrNodeExists              = zk.ErrNodeExists
	ErrNotEmpty                = zk.ErrNotEmpty
	ErrSessionExpired          = zk.ErrSessionExpired
	ErrInvalidACL              = zk.ErrInvalidACL
	ErrAuthFailed              = zk.ErrAuthFailed
	ErrClosing                 = zk.ErrClosing
	ErrNothing                 = zk.ErrNothing
	ErrSessionMoved            = zk.ErrSessionMoved
)

Functions

func Connect

func Connect(servers []string, timeout time.Duration) (*client, error)

func ContextGetTimeout

func ContextGetTimeout(ctx context.Context) time.Duration

func ContextPutTimeout

func ContextPutTimeout(ctx context.Context, t time.Duration) context.Context

func Hosts

func Hosts() []string

Determines the zookeeper hosts from ENV variables or use the default

func NewService

func NewService(ctx context.Context, url url.URL, close Dispose) (Registry, error)

Optional parameter is timeout, in Duration.

func SanitizeUrl

func SanitizeUrl(url url.URL) url.URL

Types

type Event

type Event struct {
	zk.Event
	Action string
	Note   string
}

func (Event) AsMap

func (e Event) AsMap() map[string]interface{}

func (Event) JSON

func (e Event) JSON() string

type Node

type Node struct {
	Path    string
	Value   []byte
	Members []string
	Stats   *zk.Stat
	Leaf    bool
	// contains filtered or unexported fields
}

func (*Node) Basename

func (this *Node) Basename() string

func (*Node) CheckAndIncrement

func (this *Node) CheckAndIncrement(current, increment int) (int, error)

func (*Node) Children

func (this *Node) Children() ([]*Node, error)

func (*Node) CountChildren

func (this *Node) CountChildren() int32

func (*Node) Delete

func (this *Node) Delete() error

func (*Node) FilterSubtreeNodes

func (this *Node) FilterSubtreeNodes(filter func(*Node) bool) ([]*Node, error)

Recursively go through all the children. Apply filter for each node. If filter returns true for the particular node, this node (though not necessarily all its children) will be excluded. This is useful for searching through all true by name or by whether it's a parent node or not.

func (*Node) Id

func (this *Node) Id() url.URL

func (*Node) Increment

func (this *Node) Increment(increment int) (int, error)

func (*Node) Load

func (this *Node) Load() error

func (*Node) Set

func (this *Node) Set(value []byte) error

func (*Node) SubtreeNodes

func (this *Node) SubtreeNodes() ([]*Node, error)

func (*Node) SubtreePaths

func (this *Node) SubtreePaths() ([]string, error)

func (*Node) ValueString

func (this *Node) ValueString() string

func (*Node) Version

func (this *Node) Version() int32

func (*Node) VisitSubtreeNodes

func (this *Node) VisitSubtreeNodes(accept func(*Node) bool) ([]*Node, error)

func (*Node) WatchOnce

func (this *Node) WatchOnce(f func(Event)) (chan<- bool, error)

func (*Node) WatchOnceChildren

func (this *Node) WatchOnceChildren(f func(Event)) (chan<- bool, error)

type Service

type Service interface {
	io.Closer

	Reconnect() error
	Events() <-chan Event
	CreateNode(string, []byte, bool) (*Node, error)
	PutNode(string, []byte, bool) (*Node, error)
	GetNode(string) (*Node, error)
	DeleteNode(string) error
	WatchOnce(string, func(Event)) (chan<- bool, error)
	WatchOnceChildren(string, func(Event)) (chan<- bool, error)
	Watch(string, func(Event) bool, ...func(error)) (chan<- bool, error)
	WatchChildren(string, func(Event) bool, ...func(error)) (chan<- bool, error)
}

Jump to

Keyboard shortcuts

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