[][src]Struct joyent_tokio_zookeeper::ZooKeeper

pub struct ZooKeeper { /* fields omitted */ }

A connection to ZooKeeper.

All interactions with ZooKeeper are performed by calling the methods of a ZooKeeper instance. All clones of the same ZooKeeper instance use the same underlying connection. Once a connection to a server is established, a session ID is assigned to the client. The client will send heart beats to the server periodically to keep the session valid.

The application can call ZooKeeper APIs through a client as long as the session ID of the client remains valid. If for some reason, the client fails to send heart beats to the server for a prolonged period of time (exceeding the session timeout value, for instance), the server will expire the session, and the session ID will become invalid. The ZooKeeper instance will then no longer be usable, and all futures will resolve with a protocol-level error. To make further ZooKeeper API calls, the application must create a new ZooKeeper instance.

If the ZooKeeper server the client currently connects to fails or otherwise does not respond, the client will automatically try to connect to another server before its session ID expires. If successful, the application can continue to use the client.

Some successful ZooKeeper API calls can leave watches on the "data nodes" in the ZooKeeper server. Other successful ZooKeeper API calls can trigger those watches. Once a watch is triggered, an event will be delivered to the client which left the watch at the first place. Each watch can be triggered only once. Thus, up to one event will be delivered to a client for every watch it leaves.

Implementations

impl ZooKeeper[src]

pub fn connect(
    addr: &SocketAddr
) -> impl Future<Item = (Self, impl Stream<Item = WatchedEvent, Error = ()>), Error = Error>
[src]

Connect to a ZooKeeper server instance at the given address with default parameters.

See ZooKeeperBuilder::connect.

pub fn create<D, A>(
    self,
    path: &str,
    data: D,
    acl: A,
    mode: CreateMode
) -> impl Future<Item = (Self, Result<String, Create>), Error = Error> where
    D: Into<Cow<'static, [u8]>>,
    A: Into<Cow<'static, [Acl]>>, 
[src]

Create a node with the given path with data as its contents.

The mode argument specifies additional options for the newly created node.

If mode is set to CreateMode::Ephemeral (or CreateMode::EphemeralSequential), the node will be removed by the ZooKeeper automatically when the session associated with the creation of the node expires.

If mode is set to CreateMode::PersistentSequential or CreateMode::EphemeralSequential, the actual path name of a sequential node will be the given path plus a suffix i where i is the current sequential number of the node. The sequence number is always fixed length of 10 digits, 0 padded. Once such a node is created, the sequential number will be incremented by one. The newly created node's full name is returned when the future is resolved.

If a node with the same actual path already exists in the ZooKeeper, the returned future resolves with an error of error::Create::NodeExists. Note that since a different actual path is used for each invocation of creating sequential nodes with the same path argument, calls with sequential modes will never return NodeExists.

Ephemeral nodes cannot have children in ZooKeeper. Therefore, if the parent node of the given path is ephemeral, the return future resolves to error::Create::NoChildrenForEphemerals.

If a node is created successfully, the ZooKeeper server will trigger the watches on the path left by exists calls, and the watches on the parent of the node by get_children calls.

The maximum allowable size of the data array is 1 MB (1,048,576 bytes).

pub fn set_data<D>(
    self,
    path: &str,
    version: Option<i32>,
    data: D
) -> impl Future<Item = (Self, Result<Stat, SetData>), Error = Error> where
    D: Into<Cow<'static, [u8]>>, 
[src]

Set the data for the node at the given path.

The call will succeed if such a node exists, and the given version matches the version of the node (if the given version is None, it matches any version). On success, the updated Stat of the node is returned.

This operation, if successful, will trigger all the watches on the node of the given path left by get_data calls.

The maximum allowable size of the data array is 1 MB (1,048,576 bytes).

pub fn delete(
    self,
    path: &str,
    version: Option<i32>
) -> impl Future<Item = (Self, Result<(), Delete>), Error = Error>
[src]

Delete the node at the given path.

The call will succeed if such a node exists, and the given version matches the node's version (if the given version is None, it matches any versions).

This operation, if successful, will trigger all the watches on the node of the given path left by exists API calls, and the watches on the parent node left by get_children API calls.

pub fn get_acl(
    self,
    path: &str
) -> impl Future<Item = (Self, Result<(Vec<Acl>, Stat), GetAcl>), Error = Error>
[src]

Return the ACL and Stat of the node at the given path.

If no node exists for the given path, the returned future resolves with an error of error::GetAcl::NoNode.

pub fn set_acl<A>(
    self,
    path: &str,
    acl: A,
    version: Option<i32>
) -> impl Future<Item = (Self, Result<Stat, SetAcl>), Error = Error> where
    A: Into<Cow<'static, [Acl]>>, 
[src]

Set the ACL for the node of the given path.

The call will succeed if such a node exists and the given version matches the ACL version of the node. On success, the updated Stat of the node is returned.

If no node exists for the given path, the returned future resolves with an error of error::SetAcl::NoNode. If the given version does not match the ACL version, the returned future resolves with an error of error::SetAcl::BadVersion.

impl ZooKeeper[src]

pub fn watch(self) -> WatchGlobally[src]

Add a global watch for the next chained operation.

pub fn with_watcher(self) -> WithWatcher[src]

Add a watch for the next chained operation, and return a future for any received event along with the operation's (successful) result.

pub fn exists(
    self,
    path: &str
) -> impl Future<Item = (Self, Option<Stat>), Error = Error>
[src]

Return the Stat of the node of the given path, or None if the node does not exist.

pub fn get_children(
    self,
    path: &str
) -> impl Future<Item = (Self, Option<Vec<String>>), Error = Error>
[src]

Return the names of the children of the node at the given path, or None if the node does not exist.

The returned list of children is not sorted and no guarantee is provided as to its natural or lexical order.

pub fn get_data(
    self,
    path: &str
) -> impl Future<Item = (Self, Option<(Vec<u8>, Stat)>), Error = Error>
[src]

Return the data and the Stat of the node at the given path, or None if it does not exist.

pub fn multi(self) -> MultiBuilder[src]

Start building a multi request. Multi requests batch several operations into one atomic unit.

Trait Implementations

impl Clone for ZooKeeper[src]

impl Debug for ZooKeeper[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.