{"id":15330475,"url":"https://github.com/kezhuw/zookeeper-client-rust","last_synced_at":"2025-04-05T02:07:08.694Z","repository":{"id":39671716,"uuid":"458807284","full_name":"kezhuw/zookeeper-client-rust","owner":"kezhuw","description":"ZooKeeper client writes in async rust.","archived":false,"fork":false,"pushed_at":"2024-10-16T00:24:20.000Z","size":331,"stargazers_count":24,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T01:07:17.569Z","etag":null,"topics":["rust","zookeeper","zookeeper-client"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kezhuw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-13T12:48:37.000Z","updated_at":"2024-12-10T02:45:12.000Z","dependencies_parsed_at":"2024-01-17T09:39:53.964Z","dependency_job_id":"d6ff46c3-a82c-4337-8765-2313bf5bd20a","html_url":"https://github.com/kezhuw/zookeeper-client-rust","commit_stats":{"total_commits":148,"total_committers":6,"mean_commits":"24.666666666666668","dds":0.04054054054054057,"last_synced_commit":"0c293ed4a4becffb8904e709015177848f1d69dd"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fzookeeper-client-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fzookeeper-client-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fzookeeper-client-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fzookeeper-client-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kezhuw","download_url":"https://codeload.github.com/kezhuw/zookeeper-client-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276163,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","zookeeper","zookeeper-client"],"created_at":"2024-10-01T09:53:24.925Z","updated_at":"2025-04-05T02:07:03.685Z","avatar_url":"https://github.com/kezhuw.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZooKeeper client in async rust\n[![crates.io](https://img.shields.io/crates/v/zookeeper-client)](https://crates.io/crates/zookeeper-client)\n[![docs.rs](https://img.shields.io/docsrs/zookeeper-client)](https://docs.rs/zookeeper-client)\n[![github-ci](https://github.com/kezhuw/zookeeper-client-rust/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/kezhuw/zookeeper-client-rust/actions)\n[![mit-license](https://img.shields.io/github/license/kezhuw/zookeeper-client-rust)](LICENSE)\n[![codecov](https://codecov.io/gh/kezhuw/zookeeper-client-rust/branch/master/graph/badge.svg?token=C98TXPU5ZZ)](https://codecov.io/gh/kezhuw/zookeeper-client-rust)\n[![Crates.io Total Downloads](https://img.shields.io/crates/d/zookeeper-client)](https://crates.io/keywords/zookeeper?sort=downloads)\n\nZooKeeper client writes in async rust.\n\n## Opinionated API\nThis library is written from scratch. Its API is pretty different from Java counterpart or even other Rust clients. Some of them are listed here for a glance.\n* No callbacks.\n* No catch-all watcher.\n* `StateWatcher` tracks session state updates.\n* `OneshotWatcher` tracks oneshot ZooKeeper node event.\n* `PersistentWatcher` tracks persistent and recursive persistent ZooKeeper node events.\n* No event type `XyzWatchRemoved` as Rust has `Drop`.\n* Most data operations are ordered at future creation time but not polling time.\n* Cloneable `Client` and `Client::chroot` enables session sharing cross multiple different rooted clients.\n\n## Examples\n\n### Basics\n```rust\nuse zookeeper_client as zk;\n\nlet path = \"/abc\";\nlet data = \"path_data\".as_bytes().to_vec();\nlet child_path = \"/abc/efg\";\nlet child_data = \"child_path_data\".as_bytes().to_vec();\nlet create_options = zk::CreateMode::Persistent.with_acls(zk::Acls::anyone_all());\n\nlet cluster = \"localhost:2181\";\nlet client = zk::Client::connect(cluster).await.unwrap();\nlet (_, stat_watcher) = client.check_and_watch_stat(path).await.unwrap();\n\nlet (stat, _) = client.create(path, \u0026data, \u0026create_options).await.unwrap();\nassert_eq!((data.clone(), stat), client.get_data(path).await.unwrap());\n\nlet event = stat_watcher.changed().await;\nassert_eq!(event.event_type, zk::EventType::NodeCreated);\nassert_eq!(event.path, path);\n\nlet path_client = client.clone().chroot(path).unwrap();\nassert_eq!((data, stat), path_client.get_data(\"/\").await.unwrap());\n\nlet (_, _, child_watcher) = client.get_and_watch_children(path).await.unwrap();\n\nlet (child_stat, _) = client.create(child_path, \u0026child_data, \u0026create_options).await.unwrap();\n\nlet child_event = child_watcher.changed().await;\nassert_eq!(child_event.event_type, zk::EventType::NodeChildrenChanged);\nassert_eq!(child_event.path, path);\n\nlet relative_child_path = child_path.strip_prefix(path).unwrap();\nassert_eq!((child_data.clone(), child_stat), path_client.get_data(relative_child_path).await.unwrap());\n\nlet (_, _, event_watcher) = client.get_and_watch_data(\"/\").await.unwrap();\ndrop(client);\ndrop(path_client);\n\nlet session_event = event_watcher.changed().await;\nassert_eq!(session_event.event_type, zk::EventType::Session);\nassert_eq!(session_event.session_state, zk::SessionState::Closed);\n```\n\n### Recipes\n```rust\nuse zookeeper_client as zk;\n\nlet cluster = \"localhost:2181\";\nlet client = zk::Client::connect(cluster).await.unwrap();\n\nlet prefix = zk::LockPrefix::new_curator(\"/app/locks\", \"latch-\").unwrap();\nlet options = zk::LockOptions::new(zk::Acls::anyone_all())\n    .with_ancestor_options(zk::CreateMode::Persistent.with_acls(zk::Acls::anyone_all()))\n    .unwrap();\nlet latch = client.lock(prefix, b\"\", options).await.unwrap();\nlatch.create(\"/app/data\", b\"data\", \u0026zk::CreateMode::Ephemeral.with_acls(zk::Acls::anyone_all())).await.unwrap();\n```\n\nFor more examples, see [zookeeper.rs](tests/zookeeper.rs).\n\n## License\nThe MIT License (MIT). See [LICENSE](LICENSE) for the full license text.\n\n## References\n* [ZooKeeper Documentation](https://zookeeper.apache.org/doc/current/index.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezhuw%2Fzookeeper-client-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkezhuw%2Fzookeeper-client-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezhuw%2Fzookeeper-client-rust/lists"}