Skip to content

Commit 69b7789

Browse files
committed
docs: Added timestamp generator docs
1 parent 55b556d commit 69b7789

File tree

3 files changed

+96
-52
lines changed

3 files changed

+96
-52
lines changed

docs/source/SUMMARY.md

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,76 @@
33
[Scylla Rust Driver](index.md)
44

55
- [Quick start](quickstart/quickstart.md)
6-
- [Creating a project](quickstart/create-project.md)
7-
- [Running Scylla using Docker](quickstart/scylla-docker.md)
8-
- [Connecting and running a simple query](quickstart/example.md)
6+
- [Creating a project](quickstart/create-project.md)
7+
- [Running Scylla using Docker](quickstart/scylla-docker.md)
8+
- [Connecting and running a simple query](quickstart/example.md)
99

1010
- [Migration guides](migration-guides/migration-guides.md)
11-
- [Adjusting code to changes in serialization API introduced in 0.11](migration-guides/0.11-serialization.md)
12-
- [Adjusting code to changes in deserialization API introduced in 0.15](migration-guides/0.15-deserialization.md)
11+
- [Adjusting code to changes in serialization API introduced in 0.11](migration-guides/0.11-serialization.md)
12+
- [Adjusting code to changes in deserialization API introduced in 0.15](migration-guides/0.15-deserialization.md)
1313

1414
- [Connecting to the cluster](connecting/connecting.md)
15-
- [Compression](connecting/compression.md)
16-
- [Authentication](connecting/authentication.md)
17-
- [TLS](connecting/tls.md)
15+
- [Compression](connecting/compression.md)
16+
- [Authentication](connecting/authentication.md)
17+
- [TLS](connecting/tls.md)
1818

1919
- [Making queries](queries/queries.md)
20-
- [Simple query](queries/simple.md)
21-
- [Query values](queries/values.md)
22-
- [Query result](queries/result.md)
23-
- [Prepared query](queries/prepared.md)
24-
- [Batch statement](queries/batch.md)
25-
- [Paged query](queries/paged.md)
26-
- [Lightweight transaction query (LWT)](queries/lwt.md)
27-
- [USE keyspace](queries/usekeyspace.md)
28-
- [Schema agreement](queries/schema-agreement.md)
29-
- [Query timeouts](queries/timeouts.md)
20+
- [Simple query](queries/simple.md)
21+
- [Query values](queries/values.md)
22+
- [Query result](queries/result.md)
23+
- [Prepared query](queries/prepared.md)
24+
- [Batch statement](queries/batch.md)
25+
- [Paged query](queries/paged.md)
26+
- [Lightweight transaction query (LWT)](queries/lwt.md)
27+
- [USE keyspace](queries/usekeyspace.md)
28+
- [Schema agreement](queries/schema-agreement.md)
29+
- [Query timeouts](queries/timeouts.md)
30+
- [Timestamp generators](queries/timestamp-generators.md)
3031

3132
- [Execution profiles](execution-profiles/execution-profiles.md)
32-
- [Creating a profile and setting it](execution-profiles/create-and-use.md)
33-
- [All options supported by a profile](execution-profiles/maximal-example.md)
34-
- [Options priority](execution-profiles/priority.md)
35-
- [Remapping a profile handle](execution-profiles/remap.md)
33+
- [Creating a profile and setting it](execution-profiles/create-and-use.md)
34+
- [All options supported by a profile](execution-profiles/maximal-example.md)
35+
- [Options priority](execution-profiles/priority.md)
36+
- [Remapping a profile handle](execution-profiles/remap.md)
3637

3738
- [Data Types](data-types/data-types.md)
38-
- [Bool, Tinyint, Smallint, Int, Bigint, Float, Double](data-types/primitive.md)
39-
- [Ascii, Text, Varchar](data-types/text.md)
40-
- [Counter](data-types/counter.md)
41-
- [Blob](data-types/blob.md)
42-
- [Inet](data-types/inet.md)
43-
- [Uuid](data-types/uuid.md)
44-
- [Timeuuid](data-types/timeuuid.md)
45-
- [Date](data-types/date.md)
46-
- [Time](data-types/time.md)
47-
- [Timestamp](data-types/timestamp.md)
48-
- [Duration](data-types/duration.md)
49-
- [Decimal](data-types/decimal.md)
50-
- [Varint](data-types/varint.md)
51-
- [List, Set, Map](data-types/collections.md)
52-
- [Tuple](data-types/tuple.md)
53-
- [UDT (User defined type)](data-types/udt.md)
39+
- [Bool, Tinyint, Smallint, Int, Bigint, Float, Double](data-types/primitive.md)
40+
- [Ascii, Text, Varchar](data-types/text.md)
41+
- [Counter](data-types/counter.md)
42+
- [Blob](data-types/blob.md)
43+
- [Inet](data-types/inet.md)
44+
- [Uuid](data-types/uuid.md)
45+
- [Timeuuid](data-types/timeuuid.md)
46+
- [Date](data-types/date.md)
47+
- [Time](data-types/time.md)
48+
- [Timestamp](data-types/timestamp.md)
49+
- [Duration](data-types/duration.md)
50+
- [Decimal](data-types/decimal.md)
51+
- [Varint](data-types/varint.md)
52+
- [List, Set, Map](data-types/collections.md)
53+
- [Tuple](data-types/tuple.md)
54+
- [UDT (User defined type)](data-types/udt.md)
5455

5556
- [Load balancing](load-balancing/load-balancing.md)
56-
- [Default policy](load-balancing/default-policy.md)
57+
- [Default policy](load-balancing/default-policy.md)
5758

5859
- [Retry policy configuration](retry-policy/retry-policy.md)
59-
- [Fallthrough retry policy](retry-policy/fallthrough.md)
60-
- [Default retry policy](retry-policy/default.md)
61-
- [Downgrading consistency policy](retry-policy/downgrading-consistency.md)
60+
- [Fallthrough retry policy](retry-policy/fallthrough.md)
61+
- [Default retry policy](retry-policy/default.md)
62+
- [Downgrading consistency policy](retry-policy/downgrading-consistency.md)
6263

6364
- [Speculative execution](speculative-execution/speculative.md)
64-
- [Simple](speculative-execution/simple.md)
65-
- [Latency Percentile](speculative-execution/percentile.md)
65+
- [Simple](speculative-execution/simple.md)
66+
- [Latency Percentile](speculative-execution/percentile.md)
6667

6768
- [Driver metrics](metrics/metrics.md)
6869

6970
- [Logging](logging/logging.md)
7071

7172
- [Query tracing](tracing/tracing.md)
72-
- [Tracing a simple/prepared query](tracing/basic.md)
73-
- [Tracing a paged query](tracing/paged.md)
74-
- [Tracing `Session::prepare`](tracing/prepare.md)
75-
- [Query Execution History](tracing/query-history.md)
73+
- [Tracing a simple/prepared query](tracing/basic.md)
74+
- [Tracing a paged query](tracing/paged.md)
75+
- [Tracing `Session::prepare`](tracing/prepare.md)
76+
- [Query Execution History](tracing/query-history.md)
7677

7778
- [Database schema](schema/schema.md)

docs/source/queries/queries.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Driver supports all kinds of statements supported by ScyllaDB. The following tables aim to bridge between DB concepts and driver's API.
44
They include recommendations on which API to use in what cases.
55

6-
## Kinds of CQL statements (from the CQL protocol point of view):
6+
## Kinds of CQL statements (from the CQL protocol point of view)
77

88
| Kind of CQL statement | Single | Batch |
99
|-----------------------|---------------------|------------------------------------------|
@@ -59,7 +59,7 @@ This is **NOT** strictly related to content of the CQL query string.
5959
| Load balancing | advanced if prepared, else primitive | advanced if prepared **and ALL** statements in the batch target the same partition, else primitive |
6060
| Suitable operations | most of operations | - a list of operations that needs to be executed atomically (batch LightWeight Transaction)</br> - a batch of operations targetting the same partition (as an advanced optimisation) |
6161

62-
## CQL statements - operations (based on what the CQL string contains):
62+
## CQL statements - operations (based on what the CQL string contains)
6363

6464
| CQL data manipulation statement | Recommended statement kind | Recommended Session operation |
6565
|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
@@ -86,9 +86,10 @@ This is **NOT** strictly related to content of the CQL query string.
8686

8787
For more detailed comparison and more best practices, see [doc page about paging](paged.md).
8888

89-
### Queries are fully asynchronous - you can run as many of them in parallel as you wish.
89+
### Queries are fully asynchronous - you can run as many of them in parallel as you wish
90+
91+
## `USE KEYSPACE`
9092

91-
## `USE KEYSPACE`:
9293
There is a special functionality to enable [USE keyspace](usekeyspace.md).
9394

9495
```{eval-rst}
@@ -106,4 +107,5 @@ There is a special functionality to enable [USE keyspace](usekeyspace.md).
106107
schema-agreement
107108
lwt
108109
timeouts
110+
timestamp-generators
109111
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Timestamp generators
2+
3+
If you want to generate timestamps on the client side you can provide
4+
a TimestampGenerator to a SessionBuilder when creating a Session. Then
5+
every executed statement will have attached a new timestamp generated
6+
by the provided TimestampGenerator, as longas the statement did not
7+
already have a timestamp provided (e.g. by using the `TIMESTAMP` clause).
8+
9+
## Monotonic Timestamp Generator
10+
11+
Most basic client-side timestamp generator. Guarantees monotonic timestamps
12+
based on the system clock, with automatic timestamp incrementation
13+
if the system clock timestamp would not be monotonic. If the clock skew
14+
exceeds warning_threshold of the generator (provided in the constructor, 1s by default)
15+
user will be warned with timestamp generation with warning_interval cooldown period
16+
(provided in the constructor, 1s by default) to not spam the user.
17+
18+
``` rust
19+
# extern crate scylla;
20+
# use std::error::Error;
21+
# async fn check_only_compiles() -> Result<(), Box<dyn std::error::Error>> {
22+
use scylla::{Session, SessionBuilder};
23+
use scylla::transport::timestamp_generator::MonotonicTimestampGenerator;
24+
use std::sync::Arc;
25+
use std::time::Duration;
26+
27+
let session: Session = SessionBuilder::new()
28+
.known_node("127.0.0.1:9042")
29+
.timestamp_generator(Arc::new(MonotonicTimestampGenerator::new()))
30+
.build()
31+
.await?;
32+
33+
// This query will have a timestamp generated
34+
// by the monotonic timestamp generator
35+
let my_query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(?)");
36+
let to_insert: i32 = 12345;
37+
session.query_unpaged(my_query, (to_insert,)).await?;
38+
# Ok(())
39+
# }
40+
41+

0 commit comments

Comments
 (0)