Skip to content

Commit

Permalink
docs: multiple markdown docs fixed
Browse files Browse the repository at this point in the history
Signed-off-by: lxl66566 <[email protected]>
  • Loading branch information
lxl66566 committed Sep 20, 2024
1 parent 689663d commit 35fa835
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 86 deletions.
26 changes: 13 additions & 13 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## Configurations

The Xline configuration file is written in toml format and the default path is /etc/xline_server.conf. If you need to change the path of the configuration file, you can set it via the environment variable XLINE_SERVER_CONFIG.
The Xline configuration file is written in toml format and the default path is `/etc/xline_server`.conf. If you need to change the path of the configuration file, you can set it via the environment variable `XLINE_SERVER_CONFIG`.

The configuration file has four sections, as follows:

1. cluster section: contains information about curp cluster, including basic information, cluster member configuration, curp server timeout settings (optional), curp client timeout settings (optional).
2. log section: contains the Xline log-related configuration, where path is required, rotation (optional, default value is 'daily'), level (optional, default value is 'info')
2. log section: contains the Xline log-related configuration, where path is required, rotation (optional, default value is `daily`), level (optional, default value is `info`)
3. trace section: contains the jaeger's trace mode (online or offline), trace level and the log directory in offline mode
4. auth section: contains the address of the key pair required for authentication

Expand Down Expand Up @@ -61,24 +61,24 @@ retry_timeout = '50ms' # the rpc retry interval, of which the default i

## Boot up an Xline cluster

1. Download binary from [release]() page.
1. Download binary from [release](https://github.com/xline-kv/Xline/releases) page.
2. Use the following command to start cluster:

```bash
# Run in 3 terminals. If you want more logs, add `RUST_LOG=curp=debug,xline=debug` before the command.
```bash
# Run in 3 terminals. If you want more logs, add `RUST_LOG=curp=debug,xline=debug` before the command.

./xline --name node1 --members node1=127.0.0.1:2379,node2=127.0.0.1:2380,node3=127.0.0.1:2381 --is-leader
./xline --name node1 --members node1=127.0.0.1:2379,node2=127.0.0.1:2380,node3=127.0.0.1:2381 --is-leader

./xline --name node2 --members node1=127.0.0.1:2379,node2=127.0.0.1:2380,node3=127.0.0.1:2381
./xline --name node2 --members node1=127.0.0.1:2379,node2=127.0.0.1:2380,node3=127.0.0.1:2381

./xline --name node3 --members node1=127.0.0.1:2379,node2=127.0.0.1:2380,node3=127.0.0.1:2381
```
./xline --name node3 --members node1=127.0.0.1:2379,node2=127.0.0.1:2380,node3=127.0.0.1:2381
```

3. Download or build `etcdctl` from [etcd](https://github.com/etcd-io/etcd) project.
4. Use `etcdctl` to operate the cluster:

```bash
etcdctl --endpoints=http://127.0.0.1:2379 put foo bar
```bash
etcdctl --endpoints=http://127.0.0.1:2379 put foo bar
etcdctl --endpoints=http://127.0.0.1:2379 get foo
```
etcdctl --endpoints=http://127.0.0.1:2379 get foo
```
3 changes: 3 additions & 0 deletions crates/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ This crate provides a set of utilities for locks.
## Usage

Add this to your Cargo.toml :

```Toml
[dependencies]
utils = { path = "../utils", features = ["std"] }
```

Write your code like this:

```Rust
use utils::std_lock::{MutexMap, RwLockMap};
use std::sync::{Mutex, RwLock};
Expand All @@ -31,6 +33,7 @@ assert_eq!(val, 3);
```

## Features

- `std`: utils for `std::sync::Mutex` and `std::sync::RwLock`
- `parking_lot`: utils for` parking_lot::Mutex` and `parking_lot::RwLock`
- `tokio`: utils for `tokio::sync::Mutex` and `tokio::sync::RwLock`
68 changes: 35 additions & 33 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,40 +78,41 @@ 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::{PutOptions, RangeOptions},
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("key", "value", None).await?;
let resp = client.range("key", None).await?;
// let resp = client.range("key2", Some(RangeOptions::default().with_limit(6))).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::{PutOptions, RangeOptions},
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("key", "value", None).await?;
let resp = client.range("key", None).await?;
// let resp = client.range("key2", Some(RangeOptions::default().with_limit(6))).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
Loading

0 comments on commit 35fa835

Please sign in to comment.