Skip to content

Latest commit

 

History

History
123 lines (100 loc) · 2.65 KB

README.md

File metadata and controls

123 lines (100 loc) · 2.65 KB

xline-client

Official Xline API client for Rust that supports the CURP protocol

Features

xline-client runs the CURP protocol on the client side for maximal performance.

Supported APIs

  • KV
    • Put
    • Range
    • Delete
    • Transaction
    • Compact
  • Lease
    • Grant
    • Revoke
    • KeepAlive
    • TimeToLive
    • Leases
  • Watch
    • WatchCreate
    • WatchCancel
  • Auth
    • Authenticate
    • RoleAdd
    • RoleGet
    • RoleList
    • RoleDelete
    • RoleGrantPermission
    • RoleRevokePermission
    • UserAdd
    • UserGet
    • UserList
    • UserDelete
    • UserChangePassword
    • UserGrantRole
    • UserRevokeRole
    • AuthEnable
    • AuthDisable
    • AuthStatus
  • Cluster
    • MemberAdd
    • MemberRemove
    • MemberUpdate
    • MemberList
    • MemberPromote
  • Election
    • Campaign
    • Proclaim
    • Resign
    • Leader
    • Observe
  • Lock
    • Lock
    • Unlock
  • Maintenance
    • Alarm
    • Status
    • Defragment
    • Hash
    • Snapshot
    • MoveLeader

Note that certain APIs that have not been implemented in Xline will also not be implemented in xline-client.

Getting Started

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:

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

You can find them in examples

Xline Compatibility

We aim to maintain compatibility with each corresponding Xline version, and update this library with each new Xline release.

The current library version has been tested to work with Xline v0.4.1.

Documentation

Checkout the API document (currently unavailable) on docs.rs