https://github.com/zarvd/etcd-rs
etcd client for rust
https://github.com/zarvd/etcd-rs
asynchronous etcd etcdv3 rust
Last synced: about 1 year ago
JSON representation
etcd client for rust
- Host: GitHub
- URL: https://github.com/zarvd/etcd-rs
- Owner: zarvd
- License: mit
- Archived: true
- Created: 2018-12-27T13:01:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T09:02:14.000Z (almost 3 years ago)
- Last Synced: 2025-04-03T23:01:47.358Z (about 1 year ago)
- Topics: asynchronous, etcd, etcdv3, rust
- Language: Rust
- Homepage:
- Size: 385 KB
- Stars: 197
- Watchers: 4
- Forks: 51
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
etcd client for Rust
====
[
](https://github.com/lodrem/etcd-rs)
[
](https://crates.io/crates/etcd-rs)
[
](https://docs.rs/etcd-rs)
[
](https://github.com/luncj/etcd-rs/actions?query%3Amaster)
[
](https://deps.rs/repo/github/lodrem/etcd-rs)
An [etcd](https://github.com/etcd-io/etcd) (API v3) client for Rust backed by [tokio](https://github.com/tokio-rs/tokio) and [tonic](https://github.com/hyperium/tonic).
Supported APIs
----
- KV
- [x] Put
- [x] Range
- [x] Delete
- [x] Transaction
- [x] Compact
- Lease
- [x] Grant
- [x] Revoke
- [x] KeepAlive
- [x] TimeToLive
- Watch
- [x] WatchCreate
- [x] WatchCancel
- Auth
- [x] Authenticate
- [ ] RoleAdd
- [ ] RoleGrantPermission
- [ ] UserAdd
- [ ] UserGrantRole
- [ ] AuthEnable
- [ ] AuthDisable
- Cluster
- [x] MemberAdd
- [x] MemberRemove
- [x] MemberUpdate
- [x] MemberList
- Maintenance
- [ ] Alarm
- [ ] Status
- [ ] Defragment
- [ ] Hash
- [ ] Snapshot
- [ ] MoveLeader
Usage
----
Add following dependencies in your project `cargo.toml`:
```toml
[dependencies]
etcd-rs = "1.0"
```
```rust
use etcd_rs::Client;
#[tokio::main]
async fn main() {
let cli = Client::connect(ClientConfig {
endpoints: [
"http://127.0.0.1:12379",
"http://127.0.0.1:22379",
"http://127.0.0.1:32379",
],
..Default::default()
}).await;
cli.put(("foo", "bar")).await.expect("put kv");
let kvs = cli.get("foo").await.expect("get kv").take_kvs();
assert_eq!(kvs.len(), 1);
}
```
Development
----
requirements:
- Makefile
- docker
- docker-compose
### Start local etcd cluster
```shell
make setup-etcd-cluster
```
stop cluster
```shell
make teardown-etcd-cluster
```
### Run tests
```shell
make test
```
for specified case:
```shell
TEST_CASE=test_put_error make test-one
```
License
----
This project is licensed under the [MIT license](LICENSE).