Crate cdrs_tokio

source ·
Expand description

cdrs is a native Cassandra DB client written in Rust.

Getting started

This example configures a cluster consisting of a single node, and uses round-robin load balancing.

use cdrs_tokio::cluster::session::{TcpSessionBuilder, SessionBuilder};
use cdrs_tokio::cluster::NodeTcpConfigBuilder;
use cdrs_tokio::load_balancing::RoundRobinLoadBalancingStrategy;
use std::sync::Arc;

async fn main() {
    let cluster_config = NodeTcpConfigBuilder::new()
    let session = TcpSessionBuilder::new(RoundRobinLoadBalancingStrategy::new(), cluster_config)

    let create_ks = "CREATE KEYSPACE IF NOT EXISTS test_ks WITH REPLICATION = { \
                     'class' : 'SimpleStrategy', 'replication_factor' : 1 };";
        .expect("Keyspace create error");

Nodes and load balancing

In order to maximize efficiency, the driver needs to be appropriately configured for given use case. Please look at available load balancers and node distance evaluators to pick the optimal solution when building the Session. Topology-aware load balancing is preferred when dealing with multi-node clusters, otherwise simpler strategies might prove more efficient.



  • Transforms arguments to values consumed by queries.

Type Aliases