10 releases (5 major breaking)

new 6.0.0-beta.4 Nov 25, 2021
6.0.0-beta.1 Oct 28, 2021
5.0.0 Jul 30, 2021
4.0.0 Apr 27, 2021
1.0.0 Nov 17, 2020

#142 in Database interfaces

Download history 127/week @ 2021-08-09 139/week @ 2021-08-16 108/week @ 2021-08-23 80/week @ 2021-08-30 44/week @ 2021-09-06 84/week @ 2021-09-13 110/week @ 2021-09-20 77/week @ 2021-09-27 46/week @ 2021-10-04 78/week @ 2021-10-11 150/week @ 2021-10-18 182/week @ 2021-10-25 103/week @ 2021-11-01 88/week @ 2021-11-08 142/week @ 2021-11-15 141/week @ 2021-11-22

428 downloads per month

MIT/Apache

205KB
5K SLoC

CDRS tokio crates.io version build status

CDRS tokio - async Apache Cassandra driver using tokio

CDRS is production-ready Apache Cassandra driver written in pure Rust.

Features

  • Asynchronous API;
  • TCP/TLS connection;
  • Topology-aware dynamic and configurable load balancing;
  • Configurable connection strategies;
  • LZ4, Snappy compression;
  • Cassandra-to-Rust data deserialization;
  • Pluggable authentication strategies;
  • ScyllaDB support;
  • Server events listening;
  • Multiple CQL version support (3, 4), full spec implementation;
  • Query tracing information;
  • Prepared statements;
  • Query paging;
  • Batch statements;
  • Configurable retry and reconnection policy;
  • Support for interleaved queries;
  • Support for Yugabyte YCQL JSONB;

Documentation and examples

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::RoundRobinBalancingStrategy;
use cdrs_tokio::query::*;
use std::sync::Arc;

#[tokio::main]
async fn main() {
    let cluster_config = NodeTcpConfigBuilder::new()
        .with_contact_point("127.0.0.1:9042".into())
        .build()
        .await
        .unwrap();
    let session = TcpSessionBuilder::new(RoundRobinBalancingStrategy::new(), cluster_config).build();

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

License

This project is licensed under either of

at your option.

Dependencies

~6–9.5MB
~186K SLoC