Documentation ¶
Index ¶
- Constants
- Variables
- func StartTracer(listenAddr, serverAddr string)
- type ACL
- type CheckVersionRequest
- type Conn
- func (c *Conn) AddAuth(scheme string, auth []byte) error
- func (c *Conn) Children(path string) ([]string, Stat, error)
- func (c *Conn) ChildrenW(path string) ([]string, Stat, <-chan Event, error)
- func (c *Conn) Close()
- func (c *Conn) Create(path string, data []byte, flags int32, acl []ACL) (string, error)
- func (c *Conn) CreateProtectedEphemeralSequential(path string, data []byte, acl []ACL) (string, error)
- func (c *Conn) Delete(path string, version int32) error
- func (c *Conn) Exists(path string) (bool, Stat, error)
- func (c *Conn) ExistsW(path string) (bool, Stat, <-chan Event, error)
- func (c *Conn) Get(path string) ([]byte, Stat, error)
- func (c *Conn) GetACL(path string) ([]ACL, Stat, error)
- func (c *Conn) GetW(path string) ([]byte, Stat, <-chan Event, error)
- func (c *Conn) Multi(ops MultiOps) error
- func (c *Conn) Set(path string, data []byte, version int32) (Stat, error)
- func (c *Conn) SetACL(path string, acl []ACL, version int32) (Stat, error)
- func (c *Conn) State() State
- func (c *Conn) Sync(path string) (string, error)
- type CreateRequest
- type DeleteRequest
- type Dialer
- type ErrCode
- type ErrMissingServerConfigField
- type Event
- type EventType
- type Lock
- type MultiOps
- type PathVersionRequest
- type Server
- type ServerConfig
- type ServerConfigServer
- type SetDataRequest
- type Stat
- type State
- type TestCluster
- type TestServer
Constants ¶
View Source
const ( EventNodeCreated = EventType(1) EventNodeDeleted = EventType(2) EventNodeDataChanged = EventType(3) EventNodeChildrenChanged = EventType(4) EventSession = EventType(-1) EventNotWatching = EventType(-2) )
View Source
const ( StateUnknown = State(-1) StateDisconnected = State(0) StateConnecting = State(1) StateSyncConnected = State(3) StateAuthFailed = State(4) StateConnectedReadOnly = State(5) StateSaslAuthenticated = State(6) StateExpired = State(-112) StateConnected = State(100) StateHasSession = State(101) )
View Source
const ( FlagEphemeral = 1 FlagSequence = 2 )
View Source
const ( PermRead = 1 << iota PermWrite PermCreate PermDelete PermAdmin PermAll = 0x1f )
Constants for ACL permissions
View Source
const ( DefaultServerTickTime = 2000 DefaultServerInitLimit = 10 DefaultServerSyncLimit = 5 DefaultServerAutoPurgeSnapRetainCount = 3 DefaultPeerPort = 2888 DefaultLeaderElectionPort = 3888 )
View Source
const (
DefaultPort = 2181
)
Variables ¶
View Source
var ( ErrConnectionClosed = errors.New("zk: connection closed") ErrUnknown = errors.New("zk: unknown error") ErrAPIError = errors.New("zk: api error") ErrNoNode = errors.New("zk: node does not exist") ErrNoAuth = errors.New("zk: not authenticated") ErrBadVersion = errors.New("zk: version conflict") ErrNoChildrenForEphemerals = errors.New("zk: ephemeral nodes may not have children") ErrNodeExists = errors.New("zk: node already exists") ErrNotEmpty = errors.New("zk: node has children") ErrSessionExpired = errors.New("zk: session has been expired by the server") ErrInvalidACL = errors.New("zk: invalid ACL specified") ErrAuthFailed = errors.New("zk: client authentication failed") ErrClosing = errors.New("zk: zookeeper is closing") ErrNothing = errors.New("zk: no server responsees to process") ErrSessionMoved = errors.New("zk: session moved to another server, so operation is ignored") )
View Source
var ( ErrDeadlock = errors.New("zk: trying to acquire a lock twice") ErrNotLocked = errors.New("zk: not locked") )
View Source
var ( ErrUnhandledFieldType = errors.New("zk: unhandled field type") ErrPtrExpected = errors.New("zk: encode/decode expect a non-nil pointer to struct") ErrShortBuffer = errors.New("zk: buffer too small") )
View Source
var ErrNoServer = errors.New("zk: could not connect to a server")
Functions ¶
func StartTracer ¶
func StartTracer(listenAddr, serverAddr string)
Types ¶
type ACL ¶
type CheckVersionRequest ¶
type CheckVersionRequest PathVersionRequest
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func ConnectWithDialer ¶
func (*Conn) CreateProtectedEphemeralSequential ¶
func (c *Conn) CreateProtectedEphemeralSequential(path string, data []byte, acl []ACL) (string, error)
CreateProtectedEphemeralSequential fixes a race condition if the server crashes after it creates the node. On reconnect the session may still be valid so the ephemeral node still exists. Therefore, on reconnect we need to check if a node with a GUID generated on create exists.
type DeleteRequest ¶
type DeleteRequest PathVersionRequest
type ErrMissingServerConfigField ¶
type ErrMissingServerConfigField string
func (ErrMissingServerConfigField) Error ¶
func (e ErrMissingServerConfigField) Error() string
type MultiOps ¶
type MultiOps struct { Create []CreateRequest Delete []DeleteRequest SetData []SetDataRequest Check []CheckVersionRequest }
type PathVersionRequest ¶
type ServerConfig ¶
type ServerConfig struct { TickTime int // Number of milliseconds of each tick InitLimit int // Number of ticks that the initial synchronization phase can take SyncLimit int // Number of ticks that can pass between sending a request and getting an acknowledgement DataDir string // Direcrory where the snapshot is stored ClientPort int // Port at which clients will connect AutoPurgeSnapRetainCount int // Number of snapshots to retain in dataDir AutoPurgePurgeInterval int // Purge task internal in hours (0 to disable auto purge) Servers []ServerConfigServer }
type ServerConfigServer ¶
type SetDataRequest ¶
type TestCluster ¶
type TestCluster struct { Path string Servers []TestServer }
func StartTestCluster ¶
func StartTestCluster(size int) (*TestCluster, error)
func (*TestCluster) ConnectAll ¶
func (ts *TestCluster) ConnectAll() (*Conn, error)
func (*TestCluster) Stop ¶
func (ts *TestCluster) Stop() error
type TestServer ¶
Click to show internal directories.
Click to hide internal directories.