Skip to content
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

errors: rename QueryError to ExecutionError #1185

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/queries/schema-agreement.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let session = SessionBuilder::new()

`Session::await_schema_agreement` returns a `Future` that can be `await`ed as long as schema is not in an agreement.
However, it won't wait forever; `SessionConfig` defines a timeout that limits the time of waiting. If the timeout elapses,
the return value is `Err(QueryError::RequestTimeout)`, otherwise it is `Ok(schema_version)`.
the return value is `Err(ExecutionError::SchemaAgreementTimeout)`, otherwise it is `Ok(schema_version)`.

```rust
# extern crate scylla;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/queries/timeouts.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Query timeouts

Query execution time can be limited by setting a request timeout. If a query does not complete
in the given time, then `QueryError::RequestTimeout` is returned by the driver immediately,
in the given time, then `ExecutionError::RequestTimeout` is returned by the driver immediately,
so that application logic can continue operating, but the query may still be in progress on the server.

As a side note, if one wishes custom server-side timeouts (i.e. actual interruption of query processing),
Expand Down
4 changes: 2 additions & 2 deletions examples/schema_agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{bail, Result};
use futures::TryStreamExt as _;
use scylla::client::session::Session;
use scylla::client::session_builder::SessionBuilder;
use scylla::errors::QueryError;
use scylla::errors::ExecutionError;
use std::env;
use std::time::Duration;

Expand All @@ -27,7 +27,7 @@ async fn main() -> Result<()> {

match session.await_schema_agreement().await {
Ok(_schema_version) => println!("Schema is in agreement in time"),
Err(QueryError::RequestTimeout(_)) => println!("Schema is NOT in agreement in time"),
Err(ExecutionError::RequestTimeout(_)) => println!("Schema is NOT in agreement in time"),
Err(err) => bail!(err),
};
session
Expand Down
2 changes: 1 addition & 1 deletion examples/tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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::response::query_result::QueryResult;
type Error = scylla::errors::QueryError;
type Error = scylla::errors::ExecutionError;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Expand Down
26 changes: 13 additions & 13 deletions scylla/src/client/caching_session.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::batch::{Batch, BatchStatement};
#[allow(deprecated)]
use crate::client::pager::LegacyRowIterator;
use crate::errors::QueryError;
use crate::errors::ExecutionError;
use crate::prepared_statement::PreparedStatement;
use crate::query::Query;
#[allow(deprecated)]
Expand Down Expand Up @@ -116,7 +116,7 @@ where
&self,
query: impl Into<Query>,
values: impl SerializeRow,
) -> Result<QueryResult, QueryError> {
) -> Result<QueryResult, ExecutionError> {
let query = query.into();
let prepared = self.add_prepared_statement_owned(query).await?;
self.session.execute_unpaged(&prepared, values).await
Expand All @@ -128,7 +128,7 @@ where
&self,
query: impl Into<Query>,
values: impl SerializeRow,
) -> Result<QueryPager, QueryError> {
) -> Result<QueryPager, ExecutionError> {
let query = query.into();
let prepared = self.add_prepared_statement_owned(query).await?;
self.session.execute_iter(prepared, values).await
Expand All @@ -141,7 +141,7 @@ where
query: impl Into<Query>,
values: impl SerializeRow,
paging_state: PagingState,
) -> Result<(QueryResult, PagingStateResponse), QueryError> {
) -> Result<(QueryResult, PagingStateResponse), ExecutionError> {
let query = query.into();
let prepared = self.add_prepared_statement_owned(query).await?;
self.session
Expand All @@ -157,7 +157,7 @@ where
&self,
batch: &Batch,
values: impl BatchValues,
) -> Result<QueryResult, QueryError> {
) -> Result<QueryResult, ExecutionError> {
let all_prepared: bool = batch
.statements
.iter()
Expand Down Expand Up @@ -188,7 +188,7 @@ where
&self,
query: impl Into<Query>,
values: impl SerializeRow,
) -> Result<LegacyQueryResult, QueryError> {
) -> Result<LegacyQueryResult, ExecutionError> {
let query = query.into();
let prepared = self.add_prepared_statement_owned(query).await?;
self.session.execute_unpaged(&prepared, values).await
Expand All @@ -200,7 +200,7 @@ where
&self,
query: impl Into<Query>,
values: impl SerializeRow,
) -> Result<LegacyRowIterator, QueryError> {
) -> Result<LegacyRowIterator, ExecutionError> {
let query = query.into();
let prepared = self.add_prepared_statement_owned(query).await?;
self.session.execute_iter(prepared, values).await
Expand All @@ -213,7 +213,7 @@ where
query: impl Into<Query>,
values: impl SerializeRow,
paging_state: PagingState,
) -> Result<(LegacyQueryResult, PagingStateResponse), QueryError> {
) -> Result<(LegacyQueryResult, PagingStateResponse), ExecutionError> {
let query = query.into();
let prepared = self.add_prepared_statement_owned(query).await?;
self.session
Expand All @@ -228,7 +228,7 @@ where
&self,
batch: &Batch,
values: impl BatchValues,
) -> Result<LegacyQueryResult, QueryError> {
) -> Result<LegacyQueryResult, ExecutionError> {
let all_prepared: bool = batch
.statements
.iter()
Expand All @@ -252,7 +252,7 @@ where
/// Prepares all statements within the batch and returns a new batch where every
/// statement is prepared.
/// Uses the prepared statements cache.
pub async fn prepare_batch(&self, batch: &Batch) -> Result<Batch, QueryError> {
pub async fn prepare_batch(&self, batch: &Batch) -> Result<Batch, ExecutionError> {
let mut prepared_batch = batch.clone();

try_join_all(
Expand All @@ -264,7 +264,7 @@ where
let prepared = self.add_prepared_statement(&*query).await?;
*statement = BatchStatement::PreparedStatement(prepared);
}
Ok::<(), QueryError>(())
Ok::<(), ExecutionError>(())
}),
)
.await?;
Expand All @@ -276,15 +276,15 @@ where
pub async fn add_prepared_statement(
&self,
query: impl Into<&Query>,
) -> Result<PreparedStatement, QueryError> {
) -> Result<PreparedStatement, ExecutionError> {
self.add_prepared_statement_owned(query.into().clone())
.await
}

async fn add_prepared_statement_owned(
&self,
query: impl Into<Query>,
) -> Result<PreparedStatement, QueryError> {
) -> Result<PreparedStatement, ExecutionError> {
let query = query.into();

if let Some(raw) = self.cache.get(&query.contents) {
Expand Down
Loading