falkordb-rs
FalkorDB Rust client
Usage
Installation
Just add it to your Cargo.toml, like so:
= { = "0.1.10" }
Run FalkorDB instance
Docker:
Code Example
use ;
// Connect to FalkorDB
let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379".try_into
.expect;
let client = new
.with_connection_info
.build
.expect;
// Select the social graph
let mut graph = client.select_graph;
// Create 100 nodes and return a handful
let mut nodes = graph.query
.with_timeout
.execute
.expect;
// Can also be collected, like any other iterator
while let Some = nodes.data.next
Features
tokio support
This client supports nonblocking API using the tokio runtime.
It can be enabled like so:
= { = "0.1.10", = ["tokio"] }
Currently, this API requires running within a
multi_threaded tokio scheduler, and
does not support the current_thread one, but this will probably be supported in the future.
The API uses an almost identical API, but the various functions need to be awaited:
use ;
// Connect to FalkorDB
let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379".try_into
.expect;
let client = new_async
.with_connection_info
.build
.await
.expect;
// Select the social graph
let mut graph = client.select_graph;
// Create 100 nodes and return a handful
let mut nodes = graph.query
.with_timeout
.execute
.await
.expect;
// Graph operations are asynchronous, but parsing is still concurrent:
while let Some = nodes.data.next
Note that thread safety is still up to the user to ensure, I.e. an AsyncGraph cannot simply be sent to a task spawned
by tokio and expected to be used later,
it must be wrapped in an Arc<Mutex<_>> or something similar.
SSL/TLS Support
This client is currently built upon the redis crate, and therefore supports TLS
using
its implementation, which uses either rustls or
native_tls.
This is not enabled by default, and the user ust opt-in by enabling the respective features: "rustls"/"native-tls" (
when using tokio: "tokio-rustls"/"tokio-native-tls").
For Rustls:
= { = "0.1.10", = ["rustls"] }
= { = "0.1.10", = ["tokio-rustls"] }
For Native TLS:
= { = "0.1.10", = ["native-tls"] }
= { = "0.1.10", = ["tokio-native-tls"] }
Tracing
This crate fully supports instrumentation using the tracing crate, to use
it, simply, enable the tracing feature:
= { = "0.1.10", = ["tracing"] }
Note that different functions use different filtration levels, to avoid spamming your tests, be sure to enable the correct level as you desire it.