3 stable releases

1.0.2 Jul 5, 2023
1.0.1 May 24, 2023
1.0.0 Feb 28, 2023

#8 in #client-builder

Download history 26/week @ 2024-04-03

1,713 downloads per month
Used in csdb

Apache-2.0

93KB
2K SLoC

CeresDB Rust Client

License Crates.io

Introduction

The rust client for CeresDB.

CeresDB is a high-performance, distributed, schema-less, cloud native time-series database that can handle both time-series and analytics workloads.

Support features

  • Query
  • Write

Contributing

Any contribution is welcome!

Read our Contributing Guide and make your first contribution!

License

Under Apache License 2.0.

Community and support

  • Join the user group on Slack
  • Join the user group on WeChat WeChat QR code
  • Join the user group on DingTalk: 44602802

lib.rs:

This crate provides an user-friendly client for CeresDB.

With this crate, you can access a standalone CeresDB or a CeresDB cluster and manipulates the data in it. And the underlying communication between the client the CeresDB servers is based on the gRPC, and the protocol is defined in the ceresdbproto.

Choose Mode

Two access Modes are provided by the client, Proxy and Direct:

  • When accessing CeresDB cluster by Direct mode, the requests will be sent directly to the right CeresDB instance determined by routing information.
  • When accessing CeresDB by Proxy mode, the requests are just sent to any one CeresDB instance, which takes the responsibilities for forwarding the requests.

If the client can't access the CeresDB server directly because of the network partition, Proxy mode is the only choice. Otherwise, Direct mode is suggested for better performance.

Usage

Build the client, and then manipulate the CeresDB by writing and querying.

Example

Here is an example to create a table in CeresDB by the client.


let client = Builder::new("127.0.0.1:8831".to_string(), Mode::Direct).build();
let rpc_ctx = RpcContext::default().database("public".to_string());

let create_table_sql = r#"CREATE TABLE IF NOT EXISTS ceresdb (
    str_tag string TAG,
    int_tag int32 TAG,
    var_tag varbinary TAG,
    str_field string,
    int_field int32,
    bin_field varbinary,
    t timestamp NOT NULL,
    TIMESTAMP KEY(t)) ENGINE=Analytic with
    (enable_ttl='false')"#;

let req = SqlQueryRequest {
    tables: vec!["ceresdb".to_string()],
    sql: create_table_sql.to_string(),
};
let resp = client
    .sql_query(&rpc_ctx, &req)
    .await
    .expect("Should succeed to create table");

println!("Create table result:{:?}", resp);

Dependencies

~19–30MB
~425K SLoC