Documentation ¶
Index ¶
- Constants
- Variables
- func RemoveSequentialSuffix(path string) string
- type Client
- func (c *Client) Close()
- func (c *Client) Create(path string, data []byte, acl []zk.ACL) (*ZNode, error)
- func (c *Client) CreateSequential(path string, data []byte, acl []zk.ACL) (*ZNode, error)
- func (c *Client) Delete(path string) error
- func (c *Client) Exists(path string) (bool, error)
- func (c *Client) Read(path string) (*ZNode, error)
- func (c *Client) Update(path string, data []byte, acl []zk.ACL) (*ZNode, error)
- type Pool
- type ZNode
Constants ¶
const ( // EnvZooKeeperServer environment variable containing a comma separated // list of 'host:port' pairs, pointing at ZooKeeper Server(s). // This is used by NewClientFromEnv. EnvZooKeeperServer = "ZOOKEEPER_SERVERS" // EnvZooKeeperSessionSec environment variable defining how many seconds // a session is considered valid after losing connectivity. // This is used by NewClientFromEnv. EnvZooKeeperSessionSec = "ZOOKEEPER_SESSION" // DefaultZooKeeperSessionSec is the default amount of seconds configured for the // Client timeout session, in case EnvZooKeeperSessionSec is not set. DefaultZooKeeperSessionSec = 30 // EnvZooKeeperUsername environment variable providing the username part of a digest auth credentials. // This is used by NewClientFromEnv. EnvZooKeeperUsername = "ZOOKEEPER_USERNAME" // EnvZooKeeperPassword environment variable providing the password part of a digest auth credentials. // This is used by NewClientFromEnv. EnvZooKeeperPassword = "ZOOKEEPER_PASSWORD" )
Variables ¶
var ( ErrorZNodeAlreadyExists = zk.ErrNodeExists ErrorZNodeDoesNotExist = zk.ErrNoNode ErrorZNodeHasChildren = zk.ErrNotEmpty ErrorConnectionClosed = zk.ErrConnectionClosed ErrorInvalidArguments = zk.ErrBadArguments )
Re-exporting errors from ZK library for better encapsulation.
Functions ¶
func RemoveSequentialSuffix ¶
RemoveSequentialSuffix takes the path to a sequential ZNode, maybe created via CreateSequential, and truncates the unique suffix.
See: https://zookeeper.apache.org/doc/r3.6.3/zookeeperProgrammers.html#Sequence+Nodes+--+Unique+Naming
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a go-zookeeper `zk.Conn` object.
It's designed to offer the functionalities that we will expose via the actual Terraform Provider.
func NewClient ¶
func NewClient(servers string, sessionTimeoutSec int, username string, password string) (*Client, error)
NewClient constructs a new Client instance.
func NewClientFromEnv ¶
NewClientFromEnv constructs a Client instance from environment variables.
The only mandatory environment variable is EnvZooKeeperServer.
func (*Client) Close ¶ added in v1.2.0
func (c *Client) Close()
Close the Client underlying connection.
func (*Client) Create ¶
Create a ZNode at the given path.
Note that any necessary ZNode parents will be created if absent.
func (*Client) CreateSequential ¶
CreateSequential will create a ZNode at the given path, using the Sequential Node flag.
See: https://zookeeper.apache.org/doc/r3.6.3/zookeeperProgrammers.html#Sequence+Nodes+--+Unique+Naming
This will ensure unique naming within the same parent ZNode, by appending a monotonically increasing counter in the format `%010d` (that is 10 digits with 0 (zero) padding). Note that if the `path` ends in `/`, the ZNode name will be just the counter described above. For example:
- input path -> `/this/is/a/path/`
- created znode path -> `/this/is/a/path/0000000001`
Note also that any necessary ZNode parents will be created if absent.
func (*Client) Delete ¶
Delete the given ZNode.
Note that will also delete any child ZNode, recursively.