Skip to content

Commit

Permalink
docs: Added timestamp generator docs
Browse files Browse the repository at this point in the history
  • Loading branch information
smoczy123 committed Dec 12, 2024
1 parent 55b556d commit a66210e
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 52 deletions.
97 changes: 49 additions & 48 deletions docs/source/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,76 @@
[Scylla Rust Driver](index.md)

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

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

- [Connecting to the cluster](connecting/connecting.md)
- [Compression](connecting/compression.md)
- [Authentication](connecting/authentication.md)
- [TLS](connecting/tls.md)
- [Compression](connecting/compression.md)
- [Authentication](connecting/authentication.md)
- [TLS](connecting/tls.md)

- [Making queries](queries/queries.md)
- [Simple query](queries/simple.md)
- [Query values](queries/values.md)
- [Query result](queries/result.md)
- [Prepared query](queries/prepared.md)
- [Batch statement](queries/batch.md)
- [Paged query](queries/paged.md)
- [Lightweight transaction query (LWT)](queries/lwt.md)
- [USE keyspace](queries/usekeyspace.md)
- [Schema agreement](queries/schema-agreement.md)
- [Query timeouts](queries/timeouts.md)
- [Simple query](queries/simple.md)
- [Query values](queries/values.md)
- [Query result](queries/result.md)
- [Prepared query](queries/prepared.md)
- [Batch statement](queries/batch.md)
- [Paged query](queries/paged.md)
- [Lightweight transaction query (LWT)](queries/lwt.md)
- [USE keyspace](queries/usekeyspace.md)
- [Schema agreement](queries/schema-agreement.md)
- [Query timeouts](queries/timeouts.md)
- [Timestamp generators](queries/timestamp-generators.md)

- [Execution profiles](execution-profiles/execution-profiles.md)
- [Creating a profile and setting it](execution-profiles/create-and-use.md)
- [All options supported by a profile](execution-profiles/maximal-example.md)
- [Options priority](execution-profiles/priority.md)
- [Remapping a profile handle](execution-profiles/remap.md)
- [Creating a profile and setting it](execution-profiles/create-and-use.md)
- [All options supported by a profile](execution-profiles/maximal-example.md)
- [Options priority](execution-profiles/priority.md)
- [Remapping a profile handle](execution-profiles/remap.md)

- [Data Types](data-types/data-types.md)
- [Bool, Tinyint, Smallint, Int, Bigint, Float, Double](data-types/primitive.md)
- [Ascii, Text, Varchar](data-types/text.md)
- [Counter](data-types/counter.md)
- [Blob](data-types/blob.md)
- [Inet](data-types/inet.md)
- [Uuid](data-types/uuid.md)
- [Timeuuid](data-types/timeuuid.md)
- [Date](data-types/date.md)
- [Time](data-types/time.md)
- [Timestamp](data-types/timestamp.md)
- [Duration](data-types/duration.md)
- [Decimal](data-types/decimal.md)
- [Varint](data-types/varint.md)
- [List, Set, Map](data-types/collections.md)
- [Tuple](data-types/tuple.md)
- [UDT (User defined type)](data-types/udt.md)
- [Bool, Tinyint, Smallint, Int, Bigint, Float, Double](data-types/primitive.md)
- [Ascii, Text, Varchar](data-types/text.md)
- [Counter](data-types/counter.md)
- [Blob](data-types/blob.md)
- [Inet](data-types/inet.md)
- [Uuid](data-types/uuid.md)
- [Timeuuid](data-types/timeuuid.md)
- [Date](data-types/date.md)
- [Time](data-types/time.md)
- [Timestamp](data-types/timestamp.md)
- [Duration](data-types/duration.md)
- [Decimal](data-types/decimal.md)
- [Varint](data-types/varint.md)
- [List, Set, Map](data-types/collections.md)
- [Tuple](data-types/tuple.md)
- [UDT (User defined type)](data-types/udt.md)

- [Load balancing](load-balancing/load-balancing.md)
- [Default policy](load-balancing/default-policy.md)
- [Default policy](load-balancing/default-policy.md)

- [Retry policy configuration](retry-policy/retry-policy.md)
- [Fallthrough retry policy](retry-policy/fallthrough.md)
- [Default retry policy](retry-policy/default.md)
- [Downgrading consistency policy](retry-policy/downgrading-consistency.md)
- [Fallthrough retry policy](retry-policy/fallthrough.md)
- [Default retry policy](retry-policy/default.md)
- [Downgrading consistency policy](retry-policy/downgrading-consistency.md)

- [Speculative execution](speculative-execution/speculative.md)
- [Simple](speculative-execution/simple.md)
- [Latency Percentile](speculative-execution/percentile.md)
- [Simple](speculative-execution/simple.md)
- [Latency Percentile](speculative-execution/percentile.md)

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

- [Logging](logging/logging.md)

- [Query tracing](tracing/tracing.md)
- [Tracing a simple/prepared query](tracing/basic.md)
- [Tracing a paged query](tracing/paged.md)
- [Tracing `Session::prepare`](tracing/prepare.md)
- [Query Execution History](tracing/query-history.md)
- [Tracing a simple/prepared query](tracing/basic.md)
- [Tracing a paged query](tracing/paged.md)
- [Tracing `Session::prepare`](tracing/prepare.md)
- [Query Execution History](tracing/query-history.md)

- [Database schema](schema/schema.md)
10 changes: 6 additions & 4 deletions docs/source/queries/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Driver supports all kinds of statements supported by ScyllaDB. The following tables aim to bridge between DB concepts and driver's API.
They include recommendations on which API to use in what cases.

## Kinds of CQL statements (from the CQL protocol point of view):
## Kinds of CQL statements (from the CQL protocol point of view)

| Kind of CQL statement | Single | Batch |
|-----------------------|---------------------|------------------------------------------|
Expand Down Expand Up @@ -59,7 +59,7 @@ This is **NOT** strictly related to content of the CQL query string.
| Load balancing | advanced if prepared, else primitive | advanced if prepared **and ALL** statements in the batch target the same partition, else primitive |
| 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) |

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

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

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

### Queries are fully asynchronous - you can run as many of them in parallel as you wish.
### Queries are fully asynchronous - you can run as many of them in parallel as you wish

## `USE KEYSPACE`

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

```{eval-rst}
Expand All @@ -106,4 +107,5 @@ There is a special functionality to enable [USE keyspace](usekeyspace.md).
schema-agreement
lwt
timeouts
timestamp-generators
```
41 changes: 41 additions & 0 deletions docs/source/queries/timestamp-generators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Timestamp generators

If you want to generate timestamps on the client side you can provide
a TimestampGenerator to a SessionBuilder when creating a Session. Then
every executed statement will have attached a new timestamp generated
by the provided TimestampGenerator, as longas the statement did not
already have a timestamp provided (e.g. by using the `TIMESTAMP` clause).

## Monotonic Timestamp Generator

Most basic client-side timestamp generator. Guarantees monotonic timestamps
based on the system clock, with automatic timestamp incrementation
if the system clock timestamp would not be monotonic. If the clock skew
exceeds warning_threshold of the generator (provided in the constructor, 1s by default)
user will be warned with timestamp generation with warning_interval cooldown period
(provided in the constructor, 1s by default) to not spam the user.

``` rust
# extern crate scylla;
# use std::error::Error;
# async fn check_only_compiles() -> Result<(), Box<dyn std::error::Error>> {
use scylla::{Session, SessionBuilder, query::Query};
use scylla::transport::timestamp_generator::MonotonicTimestampGenerator;
use std::sync::Arc;
use std::time::Duration;

let session: Session = SessionBuilder::new()
.known_node("127.0.0.1:9042")
.timestamp_generator(Arc::new(MonotonicTimestampGenerator::new()))
.build()
.await?;

// This query will have a timestamp generated
// by the monotonic timestamp generator
let my_query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(?)");
let to_insert: i32 = 12345;
session.query_unpaged(my_query, (to_insert,)).await?;
# Ok(())
# }


0 comments on commit a66210e

Please sign in to comment.