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

Configurable load balancing;

CDRS tokio

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

Features

  • Asynchronous API;
  • TCP/TLS connection;
  • Connection pooling;
  • 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 policy;
  • Support for interleaved queries;

Documentation and examples

  • User guide.
  • Examples.
  • API docs (release).
  • Using ScyllaDB with RUST lesson.

Getting started

Add CDRS tokio to your Cargo.toml file as a dependency:

cdrs-tokio = "desired version"
use cdrs_tokio::authenticators::NoneAuthenticatorProvider;
use cdrs_tokio::cluster::session::{new as new_session};
use cdrs_tokio::cluster::{ClusterTcpConfig, NodeTcpConfigBuilder};
use cdrs_tokio::load_balancing::RoundRobin;
use cdrs_tokio::query::*;

#[tokio::main]
async fn main() {
  let node = NodeTcpConfigBuilder::new("127.0.0.1:9042", Arc::new(NoneAuthenticatorProvider)).build();
  let cluster_config = ClusterTcpConfig(vec![node]);
  let no_compression =
    new_session(&cluster_config, RoundRobin::new()).await.expect("session should be created");

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

This example configures a cluster consisting of a single node, and uses round robin load balancing and default bb8 values for connection pool.

License

This project is licensed under either of

  • Apache License, Version 2.0, (https://raw.githubusercontent.com/krojew/cdrs-tokio/master/LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Issues

Collection of the latest Issues

krojew

krojew

help wanted
0

After introducing protocol v5, we need extensive end-to-end tests on a v5 cluster. Ideally, also regressions checks with v4.

Such tests include running all types of queries with and without compression (everything from section 4 of https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v5.spec), listening to events, using high-level Rust-to-UDT (de)serialization, using different authentication methods.

Note: use the latest Cassandra 4.0 and the master branch, since the changes are not published yet.

a1ph

a1ph

3

Hi team,

I'd like to raise this question again. It has been asked a while ago https://github.com/AlexPikalov/cdrs/issues/282 but I think it deserves better handling.

The question is basically about allowing container fields like Vec<T> in the structs that make use of TryFromUdt or TryFromRow. Currently, if a table contains an empty list, try_from_udt (try_from_row) will fail with the error above.

The proposed solution used to be to wrap all the containers in Option, but it is quite inconvenient and looks like an overkill. An empty list is a valid construct and I do not see a point in requiring that wrapping from the application-level logic.

In our fork of the repo, we have a fix, that allows empty collections. I'd like to check if there are any objections to upstream it?

Thanks, -alph

npatsakula

npatsakula

help wanted
12

Hello there!

Prepared statement creating only in single node scope. With fixed nodes observablilty and enabled load balancing it become cause of query error:

Versions

Find the latest versions by id

6.2.0 - Apr 19, 2022

New

  • derive feature built into the main crate - no need to explicitly use cdrs_tokio_helpers_derive::* anymore.

6.1.0 - Mar 10, 2022

New

  • #[must_use] on some functions.

Fixed

  • Fixed parsing NetworkTopologyStrategy.

6.0.0 - Dec 21, 2021

This version is a departure from legacy API design, stemming from the sync version migration. Due to large performance issues and lack of dynamic topology handling in earlier versions, a decision has been made to cut the ties and focus on delivering the best functionality without legacy burden. The API surface changes are quite large, but everyone is encouraged to update - the performance improvements and new features cannot be understated.

New

  • Topology-aware load balancing: TopologyAwareNodeDistanceEvaluator and TopologyAwareLoadBalancingStrategy.
  • New ReconnectionPolicy used when trying to re-establish connections to downed nodes.
  • Error now implements standard Error.
  • SessionBuilder introduced as the preferred way to create a session.
  • Added missing traits for BatchType and QueryFlags.
  • ToString implementation for SimpleServerEvent.
  • Standard trait implementations for event frames.
  • contains_column, is_empty_by_name and is_empty functions for Row.
  • Display implementation for public enums.
  • Missing traits for PreparedMetadata, Value, Consistency and ColType.
  • New PreparedMetadataFlags.
  • New ClusterMetadata representing information about a cluster.
  • Extracted protocol functionality to separate cassandra-protocol crate.
  • Passing final auth data from the server to SaslAuthenticator.
  • SpeculativeExecutionPolicy for speculative execution control.

Changed

  • All with_name fields or args in the query API are now bool instead of Option<bool>
  • flags field removed from QueryParams (flags are now derived from the other fields at serialization time)
  • Rewritten transport layer for massive performance improvements (including removing bb8). This involves changing a large portion of public API related to transport and server events.
  • Rewritten event mechanism - now you can subscribe to server events via create_event_receiver() in Session.
  • Replaced RowsMetadataFlag, QueryFlags and frame::Flags vectors with bitflags.
  • Changed Target and ChangeType enums to SchemaChangeTarget and SchemaChangeType.
  • The varint type now uses num::BigInt representation (this implies Decimal also uses "big" types).
  • Removed unstable-dynamic-cluster feature, since it wasn't working as expected and introduced performance
    penalty. Dynamic topology handling is now built-in.
  • Removed AsBytes in favor of new Serialize trait due to performance penalty.
  • Removed FromSingleByte and AsByte in favor of From/TryFrom.
  • Removed traits along with async-trait dependency: BatchExecutor, ExecExecutor, PrepareExecutor, QueryExecutor, GetConnection and CdrsSession. Everything is now embedded directly in Session.
  • Load balancing strategy now returns query plans, rather than individual nodes, and operates on cluster metadata.
  • Removed SingleNode load balancing strategy.
  • Removed empty SimpleError.
  • Renamed connect_generic_static to connect_generic.
  • Removed GetRetryPolicy.
  • Renamed ChangeSchemeOptions to SchemaChangeOptions.
  • Protocol version can now be selected at run time.
  • Value now directly contains the value in the Some variant instead of a separate body field.
  • Consistent naming convention in all builders.
  • Split protocol-level parameters from high-level statement parameters (QueryParams vs StatementParams) and simplified API.
  • add_query_prepared for batch queries now takes PreparedQuery by reference.

5.0.0 - Jul 30, 2021

New

  • Support for stateful SASL authenticators.

Changed

  • Using up-to-date lz4 crate (no more unmaintained dependency alerts).

4.0.0 - Apr 27, 2021

Fixed

  • Build problems with Rustls.
  • TLS connections sometimes not flushing all data.
  • Not setting current namespace when not using an authenticator.

New

  • New connect_generic_* functions allowing custom connection configurations (see generic_connection.rs for example usage).
  • Possibility to use custom error types which implement FromCdrsError throughout the crate.
  • Consistency now implements FromStr.
  • Pagers can be converted into PagerState.
  • Support for v4 marshaled types.
  • Copy, Clone, Ord, PartialOrd, Eq, Hash for Opcode.
  • Customizable query retry policies with built-in FallthroughRetrySession and DefaultRetryPolicy.

Changed

  • TCP configuration now owns contained data - no need to keep it alive while the config is alive.
  • ExecPager is now public.
  • Bytes now implements From for supported types, instead of Into.
  • Moved some generic types to associated types, thus removing a lot of type passing.
  • SessionPager no longer needs mutable session.
  • A lot of names have been migrated to idiomatic Rust (mainly upper camel case abbreviations).

3.0.0 - Mar 02, 2021

Fixed

  • Remembering USEd keyspaces across connections.
  • Race condition on query id overflow.

Changed

  • Removed deprecated PasswordAuthenticator.
  • Removed unused Compressor trait.
  • Large API cleanup.
  • Renamed IntoBytes to AsBytes.
  • Authenticator can now be created at runtime - removed static type parameter.
  • Removed unneeded memory allocations when parsing data.

2.1.0 - Feb 03, 2021

Fixed

  • Recreation of forgotten prepared statements.

New

  • rustls sessions constructors.

Changed

  • Updated tokio to 1.1.

2.0.0 - Jan 05, 2021

  • Support for NonZero* types.
  • Support for chrono NaiveDateTime and DateTime<Utc>.
  • Update tokio to 1.0.
  • Pager supporting QueryValues and consistency.

1.0.0 - Nov 17, 2020

Information - Updated Jun 19, 2022

Stars: 54
Forks: 17
Issues: 4

Repositories & Extras

CDRS is looking for maintainers

CDRS is Apache Cassandra driver written in pure Rust

CDRS is looking for maintainers
Http

371

A push parser for the HTTP 1

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2

A push parser for the HTTP 1

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

This library is released under the MIT License and the Apache v2 License (see License)

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

Say Hello To DataBend The Open Source Cloud Warehouse for Everyone

Databend is inspired by apache-arrow and allows you to scale your cloud warehousing, using off the shelf open source stacks & the ultra fast processing speeds you come to expect from say Bigquery

Say Hello To DataBend The Open Source Cloud Warehouse for Everyone

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

This project is duel-licensed under both the Apache licenses, so feel free to use either at your discretion

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

This project is duel-licensed under both the Apache licenses, so feel free to use either at your discretion

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀
Facebook Instagram Twitter GitHub Dribbble
Privacy