ZooKeeper client in async rust

crates.io docs.rs github-ci mit-license codecov

ZooKeeper client writes in async rust.

Features

Examples

```rust use std::time::Duration;

use zookeeper_client as zk;

let path = "/abc"; let data = "pathdata".asbytes().tovec(); let childpath = "/abc/efg"; let childdata = "childpathdata".asbytes().tovec(); let createoptions = zk::CreateOptions::new(zk::CreateMode::Persistent, zk::Acl::anyone_all());

let cluster = "localhost:2181"; let client = zk::Client::connect(cluster, Duration::fromsecs(20)).await.unwrap(); let (, statwatcher) = client.checkandwatchstat(path).await.unwrap();

let (stat, ) = client.create(path, &data, &createoptions).await.unwrap(); asserteq!((data.clone(), stat), client.getdata(path).await.unwrap());

let event = statwatcher.changed().await; asserteq!(event.eventtype, zk::EventType::NodeCreated); asserteq!(event.path, path);

let pathclient = client.clone().chroot(path).unwrap(); asserteq!((data, stat), pathclient.getdata("/").await.unwrap());

let (, _, childwatcher) = client.getandwatch_children(path).await.unwrap();

let (childstat, _) = client.create(childpath, &childdata, &createoptions).await.unwrap();

let childevent = childwatcher.changed().await; asserteq!(childevent.eventtype, zk::EventType::NodeChildrenChanged); asserteq!(child_event.path, path);

let relativechildpath = childpath.stripprefix(path).unwrap(); asserteq!((childdata.clone(), childstat), pathclient.getdata(relativechild_path).await.unwrap());

let (, _, eventwatcher) = client.getandwatchdata("/").await.unwrap(); drop(client); drop(pathclient);

let sessionevent = eventwatcher.changed().await; asserteq!(sessionevent.eventtype, zk::EventType::Session); asserteq!(sessionevent.sessionstate, zk::SessionState::Closed); ```

For more examples, see zookeeper.rs.

TODO

License

The MIT License (MIT). See LICENSE for the full license text.

References