Skip to content

Commit

Permalink
fix: a dead link in client readme
Browse files Browse the repository at this point in the history
Signed-off-by: lxl66566 <lxl66566@gmail.com>
  • Loading branch information
lxl66566 committed Jul 9, 2024
1 parent f6ee426 commit 382fbd6
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions crates/xline-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Official Xline API client for Rust that supports the [CURP](https://github.com/xline-kv/Xline/tree/master/crates/curp) protocol

# Pre-requisites
- Install `protobuf-compiler` as mentioned in [QuickStart](https://github.com/xline-kv/Xline/blob/master/doc/quick-start/README.md#install-dependencies)

- Install `protobuf-compiler` as mentioned in [QuickStart](https://github.com/xline-kv/Xline/blob/master/doc/QUICK_START.md#build-from-source)

## Features

Expand Down Expand Up @@ -77,39 +78,40 @@ Add `xline-client` to your `Cargo.toml`:
[dependencies]
xline-client = { git = "https://github.com/xline-kv/Xline.git", package = "xline-client" }
```

To create a xline client:

```rust, no_run
use xline_client::{
types::kv::{PutRequest, RangeRequest},
Client, ClientOptions,
};
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// the name and address of all curp members
let curp_members = ["10.0.0.1:2379", "10.0.0.2:2379", "10.0.0.3:2379"];
let mut client = Client::connect(curp_members, ClientOptions::default())
.await?
.kv_client();
client.put(PutRequest::new("key", "value")).await?;
let resp = client.range(RangeRequest::new("key")).await?;
if let Some(kv) = resp.kvs.first() {
println!(
"got key: {}, value: {}",
String::from_utf8_lossy(&kv.key),
String::from_utf8_lossy(&kv.value)
);
}
Ok(())
}
```
```rust, no_run
use xline_client::{
types::kv::{PutRequest, RangeRequest},
Client, ClientOptions,
};
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// the name and address of all curp members
let curp_members = ["10.0.0.1:2379", "10.0.0.2:2379", "10.0.0.3:2379"];
let mut client = Client::connect(curp_members, ClientOptions::default())
.await?
.kv_client();
client.put(PutRequest::new("key", "value")).await?;
let resp = client.range(RangeRequest::new("key")).await?;
if let Some(kv) = resp.kvs.first() {
println!(
"got key: {}, value: {}",
String::from_utf8_lossy(&kv.key),
String::from_utf8_lossy(&kv.value)
);
}
Ok(())
}
```

## Examples

Expand Down

0 comments on commit 382fbd6

Please sign in to comment.