rust-bigtable [docs]
Rust library for working with Google Bigtable Data API
Supported API Methods
Full coverage of the Bigtable Data API v2:
| Method | Description |
|---|---|
ReadRows |
Streams back the contents of all requested rows |
SampleRowKeys |
Returns a sample of row keys in the table |
MutateRow |
Mutates a row atomically |
MutateRows |
Mutates multiple rows in a batch |
CheckAndMutateRow |
Mutates a row atomically based on output of a predicate filter |
ReadModifyWriteRow |
Modifies a row atomically on the server |
PingAndWarm |
Warms up connection channels to the service |
GenerateInitialChangeStreamPartitions |
Generates initial change stream partitions |
ReadChangeStream |
Reads changes from a table's change stream |
PrepareQuery |
Prepares a GoogleSQL query for execution |
ExecuteQuery |
Executes a GoogleSQL query against a Bigtable table |
How It Works
Requests are protobuf messages generated from Google's proto definitions. These messages are converted to JSON and sent to the predefined REST endpoints. Responses are returned as serde_json::Value.
Authentication is handled via goauth with JWT tokens.
Installation
[]
= "0.6"
Configuration
Provide service account credentials from Google Cloud Console as a JSON key file:
use get_auth_token;
let token = get_auth_token?;
Usage
High-Level Wrappers
Simple wrappers for common operations:
use get_auth_token;
use wraps;
use Table;
// Read rows with limit
let token = get_auth_token?;
let table = default;
let rows = read_rows?;
// Bulk write rows (uses MutateRows - higher throughput)
let mut rows = vec!;
bulk_write_rows?;
// Write rows one at a time (uses ReadModifyWriteRow)
let mut rows = vec!;
write_rows?;
Direct API Access
For full control, use the request builder directly:
use BTRequest;
use ;
use ;
use ;
let token = get_auth_token?;
// ReadRows
let mut req = BTRequest ;
req.method.payload_mut.rows_limit = 10;
let response = req.execute?;
// MutateRow with SetCell
let mut req = BTRequest ;
let mut set_cell = new;
set_cell.family_name = Stringfrom;
set_cell.column_qualifier = encode_str;
set_cell.timestamp_micros = -1;
set_cell.value = encode_str;
let mut m = new;
m.mutation = Some;
req.method.payload_mut.row_key = encode_str;
req.method.payload_mut.mutations.push;
let response = req.execute?;
Testing
Integration tests run against a live Bigtable instance:
# Run integration tests (requires credentials)
# Run doc tests
Dependencies
protobuf/protobuf-json-mapping- Protocol buffer handling and JSON conversiongoauth/smpl_jwt- Google OAuth2 / JWT authenticationcurl- HTTP clientserde_json- JSON serialization
License
MIT