Skip to content

Commit 8e25dcb

Browse files
author
Gor Stepanyan
committed
Docs: Add serverless cluster connect code example
As there is not a serverless cluster setup in the CI, the example is wrapped under a `check_only_compiles` function which ensures the example is compiled but not run. Fixes #677
1 parent 5899fdf commit 8e25dcb

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

docs/source/connecting/connecting.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,53 @@ async fn main() -> Result<(), Box<dyn Error>> {
3434
After successfully connecting to some specified node the driver will fetch topology information about
3535
other nodes in this cluster and connect to them as well.
3636

37+
Scylla Serverless is an elastic and dynamic deployment model. When creating a `Session` you need to
38+
specify the secure connection bundle as follows:
39+
40+
```rust
41+
# extern crate scylla;
42+
# extern crate tokio;
43+
# fn check_only_compiles() {
44+
use std::path::Path;
45+
use std::error::Error;
46+
use scylla::CloudSessionBuilder;
47+
48+
#[tokio::main]
49+
async fn main() -> Result<(), Box<dyn Error>> {
50+
let session = CloudSessionBuilder::new(Path::new("config_data.yaml"))
51+
.unwrap()
52+
.build()
53+
.await
54+
.unwrap();
55+
56+
Ok(())
57+
}
58+
# }
59+
```
60+
61+
Note that the bundle file will be provided after the serverless cluster is created. Here is an example of a
62+
configuration file for a serverless cluster:
63+
64+
```yaml
65+
datacenters:
66+
datacenter1:
67+
certificateAuthorityData: CERTIFICATE_DATA
68+
server: 127.0.1.1:9142
69+
nodeDomain: cql.cluster-id.scylla.com
70+
insecureSkipTlsVerify: false
71+
authInfos:
72+
default:
73+
clientCertificateData: CERTIFICATE_DATA
74+
clientKeyData: KEY_DATA
75+
username: scylladb
76+
password: scylladb
77+
contexts:
78+
default:
79+
datacenterName: datacenter1
80+
authInfoName: default
81+
currentContext: default
82+
```
83+
3784
```eval_rst
3885
.. toctree::
3986
:hidden:

0 commit comments

Comments
 (0)