pub struct Client { /* private fields */ }
Expand description

Client encapsulates ZooKeeper session to interact with ZooKeeper cluster.

Besides semantic errors, node operations could also fail due to cluster availability and limitations, e.g. Error::ConnectionLoss, Error::QuotaExceeded and so on.

All remote operations will fail after session expired, failed or closed.

Notable behaviors

  • All cloned clients share same authentication identities.

Implementations

Connects to ZooKeeper cluster with specified session timeout.

ZooKeeper session id.

Session password.

Negotiated session timeout.

Latest session state.

Creates a StateWatcher to track state updates.

Changes root directory to given absolute path.

Errors

In case of bad root path, old client is wrapped in Result::Err.

Notable behaviors
  • Existing watchers are not affected.

Creates node with given path and data.

Notable errors

Deletes node with specified path.

Notable errors

Gets stat and data for node with given path.

Notable errors

Gets stat and data for node with given path, and watches node deletion and data change.

The watch will be triggered by:

  • Data change.
  • Node deletion.
  • Session expiration.
Notable errors

Checks stat for node with given path.

Checks stat for node with given path, and watches node creation, deletion and data change.

The watch will be triggered by:

  • Data change.
  • Node creation and deletion.
  • Session expiration.

Sets data for node with given path and returns updated stat.

Notable errors

Lists children for node with given path.

Notable errors

Lists children for node with given path, and watches node deletion, children creation and deletion.

The watch will be triggered by:

  • Children creation and deletion.
  • Node deletion.
  • Session expiration.
Notable errors

Gets stat and children for node with given path.

Notable errors

Gets stat and children for node with given path, and watches node deletion, children creation and deletion.

The watch will be triggered by:

  • Children creation and deletion.
  • Node deletion.
  • Session expiration.
Notable errors

Counts descendants number for node with given path.

Notable errors

Lists all ephemerals nodes that created by current session and starts with given path.

Notable behaviors
  • No Error::NoNode if node with give path does not exist.
  • Result will include given path if that node is ephemeral.
  • Returned paths are located at chroot but not ZooKeeper root.

Gets acl and stat for node with given path.

Notable errors

Sets acl for node with given path and returns updated stat.

Notable errors

Watches possible nonexistent path using specified mode.

The watch will be triggered by:

  • Data change, children creation and deletion.
  • Session activities.
Cautions
  • Holds returned watcher without polling events may result in memory burst.
  • See ZOOKEEPER-4466 for interferences among different watch modes for same path or paths with parent-child relationship.

Syncs with ZooKeeper leader.

Cautions

sync + read could not guarantee linearizable semantics as sync is not quorum acked and leader could change in between.

See ZOOKEEPER-1675 and ZOOKEEPER-2136 for reference.

Authenticates session using given scheme and auth identication.

Errors
Notable behaviors
  • Same auth will be resubmitted for authentication after session reestablished.
  • This method is resistent to temporary session unavailability, that means SessionState::Disconnected will not end authentication.

Gets all authentication informations attached to current session.

Requirements
  • ZooKeeper 3.7.0 and above
References

Gets data for ZooKeeper config node, that is node with path “/zookeeper/config”.

Gets stat and data for ZooKeeper config node, that is node with path “/zookeeper/config”.

Updates ZooKeeper ensemble.

Notable errors
References

See ZooKeeper Dynamic Reconfiguration.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.