Documentation ¶
Overview ¶
Copyright 2016 The Serviced Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func GetLowestSequence(ch []string) (string, error)
- func RegisterZKLogger()
- type Connection
- func (c *Connection) Children(path string) ([]string, error)
- func (c *Connection) ChildrenW(path string, cancel <-chan struct{}) ([]string, <-chan client.Event, error)
- func (c *Connection) Close()
- func (c *Connection) Create(path string, node client.Node) error
- func (c *Connection) CreateDir(path string) error
- func (c *Connection) CreateEphemeral(path string, node client.Node) (string, error)
- func (c *Connection) CreateEphemeralIfExists(path string, node client.Node) (string, error)
- func (c *Connection) CreateIfExists(path string, node client.Node) error
- func (c *Connection) Delete(path string) error
- func (c *Connection) Exists(path string) (bool, error)
- func (c *Connection) ExistsW(path string, cancel <-chan struct{}) (bool, <-chan client.Event, error)
- func (c *Connection) Get(path string, node client.Node) error
- func (c *Connection) GetW(path string, node client.Node, cancel <-chan struct{}) (<-chan client.Event, error)
- func (c *Connection) ID() int
- func (c *Connection) NewLeader(p string) (client.Leader, error)
- func (c *Connection) NewLock(p string) (client.Lock, error)
- func (c *Connection) NewTransaction() client.Transaction
- func (c *Connection) Set(path string, node client.Node) error
- func (c *Connection) SetID(i int)
- func (c *Connection) SetOnClose(onClose func(int))
- type DSN
- type Driver
- type Leader
- type Lock
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDeadlock is returned when a lock is aquired twice on the same object. ErrDeadlock = errors.New("zk: trying to acquire a lock twice") // ErrNotLocked is returned when a caller attempts to release a lock that // has not been aquired ErrNotLocked = errors.New("zk: not locked") // ErrNoLeaderFound is returned when a leader has not been elected ErrNoLeaderFound = errors.New("zk: no leader found") )
Functions ¶
func GetLowestSequence ¶
GetLowestSequence returns the lowest sequenced value ephemeral node from the list.
func RegisterZKLogger ¶
func RegisterZKLogger()
Register a logger for the Zookeeper library which will messages from their library to our application log
Types ¶
type Connection ¶
Connection is a Zookeeper based implementation of client.Connection.
func (*Connection) Children ¶
func (c *Connection) Children(path string) ([]string, error)
Children returns the children of the node at the given path.
func (*Connection) ChildrenW ¶
func (c *Connection) ChildrenW(path string, cancel <-chan struct{}) ([]string, <-chan client.Event, error)
ChildrenW returns the children of the node at the given path as well as a channel to watch for events on that node.
func (*Connection) Close ¶
func (c *Connection) Close()
Close closes the client connection to zookeeper. Calling close twice will result in a no-op.
func (*Connection) Create ¶
func (c *Connection) Create(path string, node client.Node) error
Create adds a node at the specified path
func (*Connection) CreateDir ¶
func (c *Connection) CreateDir(path string) error
CreateDir adds a dir at the specified path
func (*Connection) CreateEphemeral ¶
CreateEphemeral creates a node whose existance depends on the persistence of the connection.
func (*Connection) CreateEphemeralIfExists ¶
CreateEphemeralIfExists creates an ephemeral node at the given path if it exists.
func (*Connection) CreateIfExists ¶
func (c *Connection) CreateIfExists(path string, node client.Node) error
CreateIfExists adds a node at the specified path if the dirpath already exists.
func (*Connection) Delete ¶
func (c *Connection) Delete(path string) error
Delete recursively removes a path and its children
func (*Connection) Exists ¶
func (c *Connection) Exists(path string) (bool, error)
Exists returns true if the path exists
func (*Connection) ExistsW ¶
func (c *Connection) ExistsW(path string, cancel <-chan struct{}) (bool, <-chan client.Event, error)
ExistsW sets a watch on a node and alerts whenever it is added or removed.
func (*Connection) Get ¶
func (c *Connection) Get(path string, node client.Node) error
Get returns the node at the given path.
func (*Connection) GetW ¶
func (c *Connection) GetW(path string, node client.Node, cancel <-chan struct{}) (<-chan client.Event, error)
GetW returns the node at the given path as well as a channel to watch for events on that node.
func (*Connection) NewLeader ¶
func (c *Connection) NewLeader(p string) (client.Leader, error)
NewLeader returns a managed leader object at the given path bound to the current connection.
func (*Connection) NewLock ¶
func (c *Connection) NewLock(p string) (client.Lock, error)
NewLock creates a new lock object
func (*Connection) NewTransaction ¶
func (c *Connection) NewTransaction() client.Transaction
NewTransaction creates a new transaction object
func (*Connection) Set ¶
func (c *Connection) Set(path string, node client.Node) error
Set assigns a value to an existing node at a given path
func (*Connection) SetOnClose ¶
func (c *Connection) SetOnClose(onClose func(int))
SetOnClose performs cleanup when a connection is closed
type DSN ¶
type DSN struct { Servers []string SessionTimeout time.Duration ConnectTimeout time.Duration PerHostConnectDelay time.Duration ReconnectStartDelay time.Duration ReconnectMaxDelay time.Duration }
DSN is a Zookeeper specific struct used for connections. It can be serialized.
func NewDSN ¶
func NewDSN(servers []string, sessionTimeout time.Duration, connectTimeout time.Duration, perHostConnectDelay time.Duration, reconnectStartDelay time.Duration, reconnectMaxDelay time.Duration) DSN
NewDSN returns a new DSN object from servers and timeout.
type Driver ¶
type Driver struct{}
Driver implements a Zookeeper based client.Driver interface
func (*Driver) GetConnection ¶
func (driver *Driver) GetConnection(dsn, basePath string) (client.Connection, error)
GetConnection returns a Zookeeper connection given the dsn. The caller is responsible for closing the returned connection.
type Leader ¶
type Leader struct {
// contains filtered or unexported fields
}
Leader is an object to facilitate creating an election in zookeeper.
func (*Leader) Current ¶
Current returns the currect elected leader and deserializes it in to node. It will return ErrNoLeaderFound if no leader has been elected.
func (*Leader) ReleaseLead ¶
ReleaseLead release the current leader role. It will return ErrNotLocked if the current object is not locked.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock creates a object to facilitate create a locking pattern in zookeeper.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
func (*Transaction) Create ¶
func (t *Transaction) Create(path string, node client.Node) client.Transaction
func (*Transaction) Delete ¶
func (t *Transaction) Delete(path string) client.Transaction
func (*Transaction) Set ¶
func (t *Transaction) Set(path string, node client.Node) client.Transaction