Skip to content

Commit 7b5d3ac

Browse files
committed
examples: add cloud-rustls example
1 parent cce794d commit 7b5d3ac

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.github/workflows/serverless.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ jobs:
3131
run: rustup update
3232
- name: Check
3333
run: cargo check --verbose
34-
- name: Run cloud example
34+
- name: Run cloud-openssl example
3535
run: cargo run --example cloud-openssl -- $HOME/.ccm/serverless/config_data.yaml
36+
- name: Run cloud-rustls example
37+
run: cargo run --example cloud-rustls -- $HOME/.ccm/serverless/config_data.yaml
3638
- name: Run cloud tests
3739
run: CLOUD_CONFIG_PATH=$HOME/.ccm/serverless/config_data.yaml RUSTFLAGS="--cfg scylla_cloud_tests" RUST_LOG=trace cargo test --verbose
3840

examples/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ path = "query_history.rs"
121121
name = "cloud-openssl"
122122
path = "cloud-openssl.rs"
123123

124+
[[example]]
125+
name = "cloud-rustls"
126+
path = "cloud-rustls.rs"
127+
124128
[[example]]
125129
name = "tls-openssl"
126130
path = "tls-openssl.rs"

examples/cloud-rustls.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::env;
2+
use std::path::Path;
3+
4+
use anyhow::Result;
5+
use scylla::client::session_builder::CloudSessionBuilder;
6+
use scylla::cloud::CloudTlsProvider;
7+
8+
#[tokio::main]
9+
async fn main() -> Result<()> {
10+
println!("Connecting to SNI proxy as described in cloud config yaml ...");
11+
let config_path = env::args()
12+
.nth(1)
13+
.unwrap_or("examples/config_data.yaml".to_owned());
14+
let session = CloudSessionBuilder::new(Path::new(&config_path), CloudTlsProvider::Rustls023)
15+
.unwrap()
16+
.build()
17+
.await
18+
.unwrap();
19+
20+
session.query_unpaged("CREATE KEYSPACE IF NOT EXISTS examples_ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}",
21+
&[]).await.unwrap();
22+
session
23+
.query_unpaged("DROP TABLE IF EXISTS examples_ks.cloud;", &[])
24+
.await
25+
.unwrap();
26+
27+
println!("Ok.");
28+
29+
Ok(())
30+
}

0 commit comments

Comments
 (0)