Aerospike has officially released its Rust client to support high-throughput, low-latency applications interacting with its real-time NoSQL database.
The decision to officially adopt the previously community-supported Rust client, explains Aerospike’s Brian Porter, was driven by the growing use of Rust to build high-throughput, low-latency applications across industries such as finance, telecommunications, cloud infrastructure, and embedded systems.
Organizations such as Amazon, Cloudflare, and Discord have adopted Rust to build reliable infrastructure and eliminate classes of memory-related bugs that commonly affect C/C++-based software.
The Rust client adopts an async-first concurrency model, allowing developers to choose either the Tokio crate or async-std
as the underlying implementation. For legacy or mixed environments, it also includes a sub-crate that exposes a blocking I/O API.
In addition to atomic operations, the client supports batch commands to operate on multiple records in a single call. Version 2 of the client adds full support for read, write, delete, and UDF operations. It also enables to query records using both primary and secondary indexes, with support for pagination and limiting the number of returned records.
Other important features of the Rust client include support for replica policies and throttling as well as high-level representations for data model types like Exists, OrderedMap, and UnorderedMap.
The following snippet succinctly demonstrates how to run a query on a primary index to retrieve records that meet a given condition:
let client = ...
let mut policy = ScanPolicy::default();
policy.include_bin_data = false;
match client.scan(&policy, "test", "demo", None) {
Ok(records) => {
// process the records
},
Err(err) => println!("Error fetching record: {}", err),
}
Likewise, this is how you create a record by associating it to a key:
let key = as_key!("test", "myset", "mykey");
let bin = as_bin!("mybin", "myvalue");
match client.put(&policy, &key, &vec![&bin]) {
Ok(()) => println!("Record written"),
Err(err) => println!("Error writing record: {}", err),
}
On Aerospike’s roadmap for its Rust client are several powerful features, including support for partition queries, distributed ACID transactions, strong consistency, and full TLS support.
Aerospike offers several other client libraries to help developers build applications with its database in an idiomatic way, including Node.js, Java, Python, C, and more.