-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement timestamp generators #1128
base: main
Are you sure you want to change the base?
Changes from all commits
8496733
a87a42e
533fc43
101d94c
55b556d
a66210e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | | ||
|-----------------------|---------------------|------------------------------------------| | ||
Comment on lines
3
to
9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Thanks for the changes in this file! |
||
|
@@ -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 | | ||
|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| | ||
|
@@ -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} | ||
|
@@ -106,4 +107,5 @@ There is a special functionality to enable [USE keyspace](usekeyspace.md). | |
schema-agreement | ||
lwt | ||
timeouts | ||
timestamp-generators | ||
``` |
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). | ||
|
||
Comment on lines
+1
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 I don't think this is precise. The timestamp will be attached to the query, but the server will ignore it.
|
||
## 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. | ||
Comment on lines
+9
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 I wouldn't call it "most basic" - it is actually quite complicated. The most basic would be the one I proposed in another comment, which just naively uses |
||
|
||
``` 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(()) | ||
# } | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit: "docs/source/SUMMARY.md"
❓ Why did you change indentation in
docs/source/SUMMARY.md
file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad, automatic markdown linter changes must have gotten into the commit here and in the queries.md and I missed them, should the changes in both of these files be reverted (except the necessary ones of course)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in queries.md are fine. The formatting change in SUMMARY could be fine too, if there is some reason apart from personal preference to make it - that's why I asked the question. Afaik Markdown doesn't specify how many spaces should the indentation have, and for MdBook the example SUMMARY.md uses 4.