[−][src]Struct zookeeper_async::ZooKeeper
The client interface for interacting with a ZooKeeper cluster.
Implementations
impl ZooKeeper
[src]
pub async fn connect<W>(
connect_string: &str,
timeout: Duration,
watcher: W
) -> ZkResult<ZooKeeper> where
W: Watcher + 'static,
[src]
connect_string: &str,
timeout: Duration,
watcher: W
) -> ZkResult<ZooKeeper> where
W: Watcher + 'static,
Connect to a ZooKeeper cluster.
connect_string
: comma separated host:port pairs, each corresponding to a zk server, e.g."127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002"
If the optional chroot suffix is used the example would look like:"127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/app/a"
where the client would be rooted at"/app/a"
and all paths would be relative to this root -- ie getting/setting/etc..."/foo/bar"
would result in operations being run on"/app/a/foo/bar"
(from the server perspective).timeout
: session timeout -- how long should a client go without receiving communication from a server before considering it connection loss?watcher
: a watcher object to be notified of connection state changes.
pub async fn add_auth<S: ToString>(
&self,
scheme: S,
auth: Vec<u8>
) -> ZkResult<()>
[src]
&self,
scheme: S,
auth: Vec<u8>
) -> ZkResult<()>
Add the specified scheme
:auth
information to this connection.
See Acl
for more information.
pub async fn create(
&self,
path: &str,
data: Vec<u8>,
acl: Vec<Acl>,
mode: CreateMode
) -> ZkResult<String>
[src]
&self,
path: &str,
data: Vec<u8>,
acl: Vec<Acl>,
mode: CreateMode
) -> ZkResult<String>
Create a node with the given path
. The node data will be the given data
, and node ACL
will be the given acl
. The mode
argument specifies the behavior of the created node (see
CreateMode
for more information).
This operation, if successful, will trigger all the watches left on the node of the given
path by exists
and get_data
API calls, and the watches left on the parent node by
get_children
API calls.
Errors
If a node with the same actual path already exists in the ZooKeeper, the result will have
Err(ZkError::NodeExists)
. Note that since a different actual path is used for each
invocation of creating sequential node with the same path argument, the call should never
error in this manner.
If the parent node does not exist in the ZooKeeper, Err(ZkError::NoNode)
will be returned.
An ephemeral node cannot have children. If the parent node of the given path is ephemeral,
Err(ZkError::NoChildrenForEphemerals)
will be returned.
If the acl
is invalid or empty, Err(ZkError::InvalidACL)
is returned.
The maximum allowable size of the data array is 1 MiB (1,048,576 bytes). Arrays larger than
this will return Err(ZkError::BadArguments)
.
pub async fn delete(&self, path: &str, version: Option<i32>) -> ZkResult<()>
[src]
Delete the node with 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
node's versions).
This operation, if successful, will trigger all the watches on the node of the given path
left by exists
API calls, watches left by get_data
API calls, and the watches on the
parent node left by get_children
API calls.
Errors
If the nodes does not exist, Err(ZkError::NoNode)
will be returned.
If the given version
does not match the node's version, Err(ZkError::BadVersion)
will be
returned.
If the node has children, Err(ZkError::NotEmpty)
will be returned.
pub async fn exists(&self, path: &str, watch: bool) -> ZkResult<Option<Stat>>
[src]
Return the Stat
of the node of the given path
or None
if no such node exists.
If the watch
is true
and the call is successful (no error is returned), a watch will be
left on the node with the given path. The watch will be triggered by a successful operation
that creates/delete the node or sets the data on the node.
pub async fn exists_w<W: FnOnce(WatchedEvent) + Send + 'static>(
&self,
path: &str,
watcher: W
) -> ZkResult<Option<Stat>>
[src]
&self,
path: &str,
watcher: W
) -> ZkResult<Option<Stat>>
Return the Stat
of the node of the given path
or None
if no such node exists.
Similar to exists
, but sets an explicit watcher instead of relying on the client's base
Watcher
.
pub async fn get_acl(&self, path: &str) -> ZkResult<(Vec<Acl>, Stat)>
[src]
Return the ACL and Stat
of the node of the given path.
Errors
If no node with the given path exists, Err(ZkError::NoNode)
will be returned.
pub async fn set_acl(
&self,
path: &str,
acl: Vec<Acl>,
version: Option<i32>
) -> ZkResult<Stat>
[src]
&self,
path: &str,
acl: Vec<Acl>,
version: Option<i32>
) -> ZkResult<Stat>
Set the ACL for the node of the given path if such a node exists and the given version
matches the version of the node. Return the Stat
of the node.
Errors
If no node with the given path exists, Err(ZkError::NoNode)
will be returned.
If the given version does not match the node's version, Err(ZkError::BadVersion)
will be
returned.
pub async fn get_children(
&self,
path: &str,
watch: bool
) -> ZkResult<Vec<String>>
[src]
&self,
path: &str,
watch: bool
) -> ZkResult<Vec<String>>
Return the list of the children of the node of the given path
. The returned values are not
prefixed with the provided path
; i.e. if the database contains /path/a
and /path/b
,
the result of get_children
for "/path"
will be ["a", "b"]
.
If the watch
is true
and the call is successful (no error is returned), a watch will be
left on the node with the given path. The watch will be triggered by a successful operation
that deletes the node of the given path or creates/delete a child under the node.
The list of children returned is not sorted and no guarantee is provided as to its natural or lexical order.
Errors
If no node with the given path exists, Err(ZkError::NoNode)
will be returned.
pub async fn get_children_w<W: FnOnce(WatchedEvent) + Send + 'static>(
&self,
path: &str,
watcher: W
) -> ZkResult<Vec<String>>
[src]
&self,
path: &str,
watcher: W
) -> ZkResult<Vec<String>>
Return the list of the children of the node of the given path
.
Similar to get_children
, but sets an explicit watcher instead of relying on the client's
base Watcher
.
pub async fn get_data(
&self,
path: &str,
watch: bool
) -> ZkResult<(Vec<u8>, Stat)>
[src]
&self,
path: &str,
watch: bool
) -> ZkResult<(Vec<u8>, Stat)>
Return the data and the Stat
of the node of the given path.
If watch
is true
and the call is successful (no error is returned), a watch will be left
on the node with the given path. The watch will be triggered by a successful operation that
sets data on the node, or deletes the node.
Errors
If no node with the given path exists, Err(ZkError::NoNode)
will be returned.
pub async fn get_data_w<W: FnOnce(WatchedEvent) + Send + 'static>(
&self,
path: &str,
watcher: W
) -> ZkResult<(Vec<u8>, Stat)>
[src]
&self,
path: &str,
watcher: W
) -> ZkResult<(Vec<u8>, Stat)>
Return the data and the Stat
of the node of the given path.
Similar to get_data
, but sets an explicit watcher instead of relying on the client's
base Watcher
.
pub async fn set_data(
&self,
path: &str,
data: Vec<u8>,
version: Option<i32>
) -> ZkResult<Stat>
[src]
&self,
path: &str,
data: Vec<u8>,
version: Option<i32>
) -> ZkResult<Stat>
Set the data for the node of the given path
if such a node exists and the given version
matches the version of the node (if the given version is None
, it matches any node's
versions). Return the Stat
of the node.
This operation, if successful, will trigger all the watches on the node of the given path
left by get_data
calls.
Errors
If no node with the given path
exists, Err(ZkError::NoNode)
will be returned.
If the given version does not match the node's version, Err(ZkError::BadVersion)
will be
returned.
The maximum allowable size of the data
array is 1 MiB (1,048,576 bytes). Arrays larger
than this will return Err(ZkError::BadArguments)
.
pub fn add_listener<Listener: Fn(ZkState) + Send + 'static>(
&self,
listener: Listener
) -> Subscription
[src]
&self,
listener: Listener
) -> Subscription
Adds a state change Listener
, which will be notified of changes to the client's ZkState
.
A unique identifier is returned, which is used in remove_listener
to un-subscribe.
pub fn remove_listener(&self, sub: Subscription)
[src]
Removes a state change Listener
and closes the channel.
pub async fn close(&self) -> ZkResult<()>
[src]
Close this client object. Once the client is closed, its session becomes invalid. All the ephemeral nodes in the ZooKeeper server associated with the session will be removed. The watches left on those nodes (and on their parents) will be triggered.
NOTE: Due to missing support for async drop at the moment, dropping self will not call close.
Trait Implementations
impl ZooKeeperExt for ZooKeeper
[src]
pub fn ensure_path<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str
) -> Pin<Box<dyn Future<Output = ZkResult<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
path: &'life1 str
) -> Pin<Box<dyn Future<Output = ZkResult<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
pub fn ensure_path_with_leaf_mode<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
mode: CreateMode
) -> Pin<Box<dyn Future<Output = ZkResult<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
path: &'life1 str,
mode: CreateMode
) -> Pin<Box<dyn Future<Output = ZkResult<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
pub fn get_children_recursive<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str
) -> Pin<Box<dyn Future<Output = ZkResult<Vec<String>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
path: &'life1 str
) -> Pin<Box<dyn Future<Output = ZkResult<Vec<String>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
pub fn delete_recursive<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str
) -> Pin<Box<dyn Future<Output = ZkResult<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
path: &'life1 str
) -> Pin<Box<dyn Future<Output = ZkResult<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl !RefUnwindSafe for ZooKeeper
[src]
impl Send for ZooKeeper
[src]
impl Sync for ZooKeeper
[src]
impl Unpin for ZooKeeper
[src]
impl !UnwindSafe for ZooKeeper
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,