From 382fbd6f03522ddcb3fa6d4cba0dc86e6c05be7f Mon Sep 17 00:00:00 2001 From: lxl66566 Date: Tue, 9 Jul 2024 21:23:07 +0800 Subject: [PATCH] fix: a dead link in client readme Signed-off-by: lxl66566 --- crates/xline-client/README.md | 66 ++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/crates/xline-client/README.md b/crates/xline-client/README.md index 9a7328c76..fb9521c2a 100644 --- a/crates/xline-client/README.md +++ b/crates/xline-client/README.md @@ -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 @@ -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