Skip to content

Commit

Permalink
Merge pull request scylladb#1093 from wprzytula/new-deserialization-a…
Browse files Browse the repository at this point in the history
…pi-upper-layer-heroes

Introduce new deserialization framework upper layer abstractions
  • Loading branch information
wprzytula authored Nov 6, 2024
2 parents 64b4afc + b0fabe5 commit dce9e9f
Show file tree
Hide file tree
Showing 21 changed files with 3,389 additions and 1,517 deletions.
65 changes: 65 additions & 0 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/cqlsh-rs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustyline::error::ReadlineError;
use rustyline::{CompletionType, Config, Context, Editor};
use rustyline_derive::{Helper, Highlighter, Hinter, Validator};
use scylla::transport::Compression;
use scylla::{QueryResult, Session, SessionBuilder};
use scylla::{LegacyQueryResult, Session, SessionBuilder};
use std::env;

#[derive(Helper, Highlighter, Validator, Hinter)]
Expand Down Expand Up @@ -173,7 +173,7 @@ impl Completer for CqlHelper {
}
}

fn print_result(result: &QueryResult) {
fn print_result(result: &LegacyQueryResult) {
if result.rows.is_none() {
println!("OK");
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct SessionService {

// A trivial service implementation for sending parameterless simple string requests to Scylla.
impl Service<scylla::query::Query> for SessionService {
type Response = scylla::QueryResult;
type Response = scylla::LegacyQueryResult;
type Error = scylla::transport::errors::QueryError;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;

Expand Down
12 changes: 6 additions & 6 deletions examples/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use scylla::statement::{
prepared_statement::PreparedStatement, query::Query, Consistency, SerialConsistency,
};
use scylla::tracing::TracingInfo;
use scylla::transport::iterator::RowIterator;
use scylla::QueryResult;
use scylla::transport::iterator::LegacyRowIterator;
use scylla::LegacyQueryResult;
use scylla::{Session, SessionBuilder};
use std::env;
use std::num::NonZeroU32;
Expand Down Expand Up @@ -42,7 +42,7 @@ async fn main() -> Result<()> {
query.set_serial_consistency(Some(SerialConsistency::LocalSerial));

// QueryResult will contain a tracing_id which can be used to query tracing information
let query_result: QueryResult = session.query_unpaged(query.clone(), &[]).await?;
let query_result: LegacyQueryResult = session.query_unpaged(query.clone(), &[]).await?;
let query_tracing_id: Uuid = query_result
.tracing_id
.ok_or_else(|| anyhow!("Tracing id is None!"))?;
Expand Down Expand Up @@ -79,14 +79,14 @@ async fn main() -> Result<()> {
// To trace execution of a prepared statement tracing must be enabled for it
prepared.set_tracing(true);

let execute_result: QueryResult = session.execute_unpaged(&prepared, &[]).await?;
let execute_result: LegacyQueryResult = session.execute_unpaged(&prepared, &[]).await?;
println!("Execute tracing id: {:?}", execute_result.tracing_id);

// PAGED QUERY_ITER EXECUTE_ITER
// It's also possible to trace paged queries like query_iter or execute_iter
// After iterating through all rows iterator.get_tracing_ids() will give tracing ids
// for all page queries
let mut row_iterator: RowIterator = session.query_iter(query, &[]).await?;
let mut row_iterator: LegacyRowIterator = session.query_iter(query, &[]).await?;

while let Some(_row) = row_iterator.next().await {
// Receive rows
Expand All @@ -105,7 +105,7 @@ async fn main() -> Result<()> {
batch.set_tracing(true);

// Run the batch and print its tracing_id
let batch_result: QueryResult = session.batch(&batch, ((),)).await?;
let batch_result: LegacyQueryResult = session.batch(&batch, ((),)).await?;
println!("Batch tracing id: {:?}\n", batch_result.tracing_id);

// CUSTOM
Expand Down
3 changes: 3 additions & 0 deletions scylla-cql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ lz4_flex = { version = "0.11.1" }
async-trait = "0.1.57"
serde = { version = "1.0", features = ["derive"], optional = true }
time-03 = { package = "time", version = "0.3", optional = true }
yoke = { version = "0.7", features = ["derive"] }
stable_deref_trait = "1.2"

[dev-dependencies]
assert_matches = "1.5.0"
criterion = "0.4" # Note: v0.5 needs at least rust 1.70.0
lazy_static = "1" # We can migrate to std::sync::LazyLock once MSRV is bumped to 1.80.
# Use large-dates feature to test potential edge cases
time-03 = { package = "time", version = "0.3.21", features = ["large-dates"] }
uuid = { version = "1.0", features = ["v4"] }
Expand Down
Loading

0 comments on commit dce9e9f

Please sign in to comment.