ZooKeeper client in async rust
ZooKeeper client writes in async rust.
Features
- No callbacks.
- No catch-all watcher.
StateWatcher
trackes session state updates.OneshotWatcher
tracks oneshot ZooKeeper node event.PersistentWatcher
tracks persistent and recursive persistent ZooKeeper node events.- No event type
XyzWatchRemoved
as there is no way to receive such event after watchers dropped. - Cloneable
Client
andClient::chroot
enables session sharing cross multiple different rooted clients.
Examples
Basics
use zookeeper_client as zk;
let path = "/abc";
let data = "path_data".as_bytes.to_vec;
let child_path = "/abc/efg";
let child_data = "child_path_data".as_bytes.to_vec;
let create_options = Persistent.with_acls;
let cluster = "localhost:2181";
let client = connect.await.unwrap;
let = client.check_and_watch_stat.await.unwrap;
let = client.create.await.unwrap;
assert_eq!;
let event = stat_watcher.changed.await;
assert_eq!;
assert_eq!;
let path_client = client.clone.chroot.unwrap;
assert_eq!;
let = client.get_and_watch_children.await.unwrap;
let = client.create.await.unwrap;
let child_event = child_watcher.changed.await;
assert_eq!;
assert_eq!;
let relative_child_path = child_path.strip_prefix.unwrap;
assert_eq!;
let = client.get_and_watch_data.await.unwrap;
drop;
drop;
let session_event = event_watcher.changed.await;
assert_eq!;
assert_eq!;
Recipes
use zookeeper_client as zk;
let cluster = "localhost:2181";
let client = connect.await.unwrap;
let prefix = new_curator.unwrap;
let options = new
.with_ancestor_options
.unwrap;
let latch = client.lock.await.unwrap;
latch.create.await.unwrap;
For more examples, see zookeeper.rs.
TODO
- Sasl authentication
License
The MIT License (MIT). See LICENSE for the full license text.