Rust developing
Building
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
git clone https://github.com/stargate/stargate-grpc-rust-client stargate-grpc
cd stargate-grpc
cargo build
Running the examples
For your convenience, this project contains a bunch of examples located in the examples directory, which demonstrate connecting, creating schemas, inserting data and querying. You’ll need a working instance of a Stargate cluster to run the examples. Refer to the official Stargate Installation documentation for more details on how to setup Stargate.
Each example program accepts an URL of the Stargate coordinator, the authentication token and the keyspace name:
cargo run --example <example> [-- [--keyspace <keyspace>] [--token <token>] [--tls] [<url>]]
The authentication token value can be also defined in the SG_TOKEN environment variable.
Run examples
Run the keyspace
example to test the connection and create the test
keyspace with the default keyspace name of stargate_examples
:
cargo run --example keyspace
Connected to http://127.0.0.2:8090
Created keyspace stargate_examples
Run the query
example to create a keyspace and table, insert some data, and
select data to check the insertion:
cargo run --example query
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/examples/basic`
Connected to http://127.0.0.2:8090
Created schema
Inserted data. Now querying.
All rows:
2 user_2 ["user_2@example.net", "user_2@mail.example.net"]
3 user_3 ["user_3@example.net", "user_3@mail.example.net"]
7 user_7 ["user_7@example.net", "user_7@mail.example.net"]
9 user_9 ["user_9@example.net", "user_9@mail.example.net"]
4 user_4 ["user_4@example.net", "user_4@mail.example.net"]
0 user_0 ["user_0@example.net", "user_0@mail.example.net"]
8 user_8 ["user_8@example.net", "user_8@mail.example.net"]
5 user_5 ["user_5@example.net", "user_5@mail.example.net"]
6 user_6 ["user_6@example.net", "user_6@mail.example.net"]
1 user_1 ["user_1@example.net", "user_1@mail.example.net"]
Row with id = 1:
1 user_1 ["user_1@example.net", "user_1@mail.example.net"]