• Stars
    star
    128
  • Rank 279,433 (Top 6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cassandra (CQL) driver for Rust, using the DataStax C/C++ driver under the covers.

Build Status Current Version License

cassandra-cpp

This is a maintained Rust project that exposes the DataStax cpp driver at https://github.com/datastax/cpp-driver/ in a somewhat-sane crate. It was originally a fork of https://github.com/tupshin/cassandra-rs but that is no longer maintained.

It is a wrapper around the raw driver binding crate cassandra-cpp-sys.

Documentation (crates.io).

Getting started

Local environment

For this crate to work, you must first have installed a sufficiently-recent version of the datastax-cpp driver (at least 2.16). Follow the steps in the cpp driver docs to do so. Pre-built packages are available for most platforms.

Make sure that the driver (specifically libcassandra_static.a and libcassandra.so) are in your /usr/local/lib64/ directory

Floki

Alternatively you can use the Floki utility to create you a Dockerized compilation environment. After installing Floki, just type

floki

in the root of this project. You will be dropped into a Rust compilation environment; type cargo build as normal to build the driver.

Documentation

See the API documentation.

The Cassandra Query Language (CQL) documentation is likely to be useful.

Since this crate provides a relatively thin wrapper around the DataStax driver, you may also find the DataStax documentation and API docs useful.

Example

For a straightforward example see simple.rs.

There are additional examples included with the project in tests and examples.

New session API (version 2.0)

Version 2.0 introduces a new and safer API. Statements (and PreparedStatement and Batch) are now associated with a specific Session. In addition, the legacy .wait() API is removed in favour of the now-ubiquitous .await.

  • This crate's functions have became async, meaning they can only be called as part of an asynchronous workflow. To use these functions, you can either call them from within an asynchronous function using the .await operator, or you can call them from a synchronous context using the block_on method from tokio runtime.

  • The stmt! macro and Statement::new method have been replaced with the Session::statement() method, which records the association with the session. Simply update your code to use the new method instead of the macro to continue using its functionality.

  • Statements are executed with .execute(), which consumes the statement: you cannot execute the same statement twice; if you need this, recreate the statement.

  • Batch::new is removed in favour of Session::batch.

  • There is a new error, BatchSessionMismatch, which occurs if you try to add statements from different Sessions into the same Batch.

  • Connection methods are tidied up. Cluster::connect_async is removed since Cluster::connect is now async. Session::connect and Session::connect_keyspace are removed - use Cluster::connect and Cluster::connect_keyspace instead.

  • Session::close (which allowed waiting until in-flight requests on the session were complete) is removed because it is non-trivial to implement safely. This functionality is no longer supported.

  • Cluster::set_ssl now consumes its argument, for improved safety.

Futures (version 0.15)

Since version 0.15, this crate uses std::future, allowing your code to use futures:0.3, async/await, etc.

Previous versions (up to 0.14) used futures:0.1. You can either remain on the 0.14 stream, update your code to use std::future, or use a compatibility shim (e.g., futures::compat).

Migrating from version 0.8

The API changed significantly in version 0.10. (Version 0.9 was skipped, for consistency with the cassandra-cpp-sys version number.) For a summary of the main changes, see CHANGELOG.

Feature flags

This crate includes the feature flag early_access_min_tls_version, which allows you to build against a version of the DataStax driver including the cass_ssl_set_min_protocol_version method, as defined in this PR. You must have a version of the driver supporting this installed locally to be able to compile (and run) with this feature flag.

When this this feature is available in the mainline driver this flag will be set to do nothing and deprecated, and the functions will be added to the main library. The flag will then be retired in the next breaking change.

License

This code is open source, licensed under the Apache License Version 2.0 as described in LICENSE.

Contributing

Please see CONTRIBUTING.md for details on how to contribute to this project.

Development

This crate is regularly built by Travis; to see details of the most recent builds click on the "build" badge at the top of this page.

You must have the DataStax driver installed on your system in order to build this crate.

The unit tests assume Cassandra is running on the local host accessible on the standard port. The easiest way to achieve this is using Docker and the standard Cassandra image, with

docker pull cassandra
docker run -d --net=host --name=cassandra cassandra

You should run them single-threaded to avoid the dreaded org.apache.cassandra.exceptions.ConfigurationException: Column family ID mismatch error. The tests share a keyspace and tables, so if run in parallel they interfere with each other.

cargo test -- --test-threads 1

Remember to destroy the container when you're done:

docker stop cassandra
docker rm cassandra

History

This project was forked from cassandra, which was no longer being maintained.

More Repositories

1

swagger-rs

A set of common utilities for crates generated by swagger-codegen
Rust
96
star
2

floki

Launch containers to help build your software
Rust
65
star
3

clearwater-docker

Docker integration for Project Clearwater
Dockerfile
41
star
4

sprout

sprout and bono, the Clearwater SIP router and edge proxy
C++
37
star
5

freeDiameter

Git mirror of freeDiameter from http://www.freediameter.net/
C
33
star
6

vault-client

A Rust client library for HashiCorp Vault
Rust
32
star
7

chronos

A distributed, redundant, reliable timer service.
C++
26
star
8

clearwater-docs

Clearwater deployment-wide documentation hub.
25
star
9

uml_parser

Rust UML parser library
Rust
20
star
10

clearwater-heat

OpenStack Heat templates for Clearwater deployments
11
star
11

Vigil

Software watchdog library for Rust services
Rust
10
star
12

crest

Crest is a RESTful HTTP server built on top of Cassandra using Tornado. It powers Clearwater's Homer and Homestead provisioning components.
Python
10
star
13

clearwater-infrastructure

Clearwater infrastructure Debian packages
Shell
8
star
14

ellis

Clearwater provisioning server
Python
8
star
15

cassandra-sys-rs

Simple mostly-autogenerated wrapper around the DataStax C/C++ CQL driver.
Rust
8
star
16

sendpacket

A high-level rust library for low-level network data.
Rust
7
star
17

libmicrohttpd

GNU libmicrohttpd
C
7
star
18

restund

Import of restund from http://www.creytiv.com/restund.html
C
6
star
19

cpp-common

Common C/C++ modules for Clearwater components
C++
6
star
20

clearwater-live-test

Scripted testing of a Clearwater deployment
Ruby
5
star
21

homestead

Clearwater Homestead HSS Cache/Gateway
C++
4
star
22

cargo-swagger

Rust
4
star
23

clearwater-etcd

Wrappers around etcd for ease of integration into Project Clearwater
Python
4
star
24

sipp

Fork of sipp from git://git.code.sf.net/p/sipp/git
C++
3
star
25

ralf

The Clearwater CTF
C++
3
star
26

frunk-enum

Extensions to frunk (https://github.com/lloydmeta/frunk) to allow transmogrification of `enum` types
Rust
2
star
27

python-common

Common python utilities and function library.
Python
2
star
28

sasclient.py

Python SAS client library
Python
2
star
29

clearwater-logging

Clearwater logging infrastructure
Shell
2
star
30

sas-client

Service Assurance Server client library
C++
2
star
31

clearwater-snmp-handlers

SNMP extension modules to provide stats for Clearwater nodes
C++
2
star
32

clearwater-monit

Cloned from Monit on bitbucket
C
2
star
33

clearwater-readthedocs

Source repository for Clearwater's ReadTheDocs.org documentation
Makefile
2
star
34

chef

Repo to hold chef recipes for Clearwater deployment
Ruby
2
star
35

clearwater-onap

Project Clearwater - ONAP compliant HEAT templates
2
star
36

libre-upstream

Import of libre from http://www.creytiv.com/re.html
C
1
star
37

clearwater-website-archive

An archive of projectclearwater.org
1
star
38

clearwater-etcd-plugins

Plugins for clearwater-etcd
Python
1
star
39

plivo-apps

Sample Plivo applications for Clearwater
Python
1
star
40

clearwater-build-infra

Clearwater common build infrastructure.
Makefile
1
star
41

pjsip-upstream

Git mirror of pjsip from http://www.pjsip.org/
C
1
star
42

clearwater-perf-utils

Python
1
star
43

announcer

Announce changes in keepachangelog-style CHANGELOG.md files to Slack and Microsoft Teams
Python
1
star
44

iobuffer

Rust crate iobuffer - a memory-based buffer which implements Write and Read traits.
Rust
1
star
45

astaire

Astaire, an active resynchronization tool for Memcached clusters
C++
1
star
46

libmemcached-upstream

Import of libmemcached from https://launchpad.net/libmemcached
C++
1
star
47

clearwater-seagull

Seagull code integrated with Project Clearwater
C++
1
star
48

serde-xml-rs

Rust
1
star
49

clearwater-vm-images

Tools for creating Virtual Machine images for Clearwater
Shell
1
star