Skip to content

Commit

Permalink
errors: move errors module to transport module
Browse files Browse the repository at this point in the history
Originally, all errors could be found under scylla::transport::errors.
Let's retain the same path.
  • Loading branch information
muzarski committed Sep 18, 2024
1 parent 8dccf6c commit 043e73f
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion examples/schema_agreement.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{bail, Result};
use futures::TryStreamExt;
use scylla::errors::QueryError;
use scylla::transport::errors::QueryError;
use scylla::transport::session::Session;
use scylla::SessionBuilder;
use std::env;
Expand Down
2 changes: 1 addition & 1 deletion examples/tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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 Error = scylla::errors::QueryError;
type Error = scylla::transport::errors::QueryError;
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
4 changes: 2 additions & 2 deletions scylla/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
time::SystemTime,
};

use crate::{errors::QueryError, retry_policy::RetryDecision};
use crate::{retry_policy::RetryDecision, transport::errors::QueryError};
use chrono::{DateTime, Utc};

use tracing::warn;
Expand Down Expand Up @@ -455,10 +455,10 @@ mod tests {
};

use crate::{
errors::{DbError, QueryError},
query::Query,
retry_policy::RetryDecision,
test_utils::setup_tracing,
transport::errors::{DbError, QueryError},
utils::test_utils::unique_keyspace_name,
};

Expand Down
1 change: 0 additions & 1 deletion scylla/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ pub mod authentication;
#[cfg(feature = "cloud")]
pub mod cloud;

pub mod errors;
pub mod history;
pub mod routing;
pub mod statement;
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/statement/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ pub(crate) mod batch_values {
use scylla_cql::types::serialize::row::SerializedValues;
use scylla_cql::types::serialize::{RowWriter, SerializationError};

use crate::errors::QueryError;
use crate::routing::Token;
use crate::transport::errors::QueryError;

use super::BatchStatement;

Expand Down
2 changes: 1 addition & 1 deletion scylla/src/statement/prepared_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use thiserror::Error;
use uuid::Uuid;

use super::{PageSize, StatementConfig};
use crate::errors::{BadQuery, QueryError};
use crate::frame::response::result::PreparedMetadata;
use crate::frame::types::{Consistency, SerialConsistency};
use crate::history::HistoryListener;
use crate::retry_policy::RetryPolicy;
use crate::routing::Token;
use crate::transport::errors::{BadQuery, QueryError};
use crate::transport::execution_profile::ExecutionProfileHandle;
use crate::transport::partitioner::{Partitioner, PartitionerHasher, PartitionerName};

Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/caching_session.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::batch::{Batch, BatchStatement};
use crate::errors::QueryError;
use crate::prepared_statement::PreparedStatement;
use crate::query::Query;
use crate::statement::{PagingState, PagingStateResponse};
use crate::transport::errors::QueryError;
use crate::transport::iterator::RowIterator;
use crate::transport::partitioner::PartitionerName;
use crate::{QueryResult, Session};
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/cluster.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::errors::{BadQuery, NewSessionError, QueryError};
/// Cluster manages up to date information and connections to database nodes
use crate::frame::response::event::{Event, StatusChangeEvent};
use crate::prepared_statement::TokenCalculationError;
use crate::routing::{Shard, Token};
use crate::transport::errors::{BadQuery, NewSessionError, QueryError};
use crate::transport::host_filter::HostFilter;
use crate::transport::session::TABLET_CHANNEL_SIZE;
use crate::transport::{
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use tokio_openssl::SslStream;
pub(crate) use ssl_config::SslConfig;

use crate::authentication::AuthenticatorProvider;
use crate::errors::{
use crate::transport::errors::{
BadKeyspaceName, BrokenConnectionError, BrokenConnectionErrorKind, ConnectionError,
ConnectionSetupRequestError, ConnectionSetupRequestErrorKind, CqlEventHandlingError, DbError,
QueryError, RequestError, ResponseParseError, TranslationError, UserRequestError,
Expand Down Expand Up @@ -2709,7 +2709,7 @@ mod tests {
#[ntest::timeout(20000)]
#[cfg(not(scylla_cloud_tests))]
async fn connection_is_closed_on_no_response_to_keepalives() {
use crate::errors::BrokenConnectionErrorKind;
use crate::transport::errors::BrokenConnectionErrorKind;

setup_tracing();

Expand Down
4 changes: 3 additions & 1 deletion scylla/src/transport/connection_pool.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#[cfg(feature = "cloud")]
use crate::cloud::set_ssl_config_for_scylla_cloud_host;

use crate::errors::{BrokenConnectionErrorKind, ConnectionError, ConnectionPoolError, QueryError};
use crate::routing::{Shard, ShardCount, Sharder};
use crate::transport::errors::{
BrokenConnectionErrorKind, ConnectionError, ConnectionPoolError, QueryError,
};
use crate::transport::{
connection,
connection::{Connection, ConnectionConfig, ErrorReceiver, VerifiedKeyspaceName},
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/downgrading_consistency_retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use scylla_cql::Consistency;
use tracing::debug;

use crate::{
errors::{DbError, QueryError, WriteType},
retry_policy::{QueryInfo, RetryDecision, RetryPolicy, RetrySession},
transport::errors::{DbError, QueryError, WriteType},
};

/// Downgrading consistency retry policy - retries with lower consistency level if it knows\
Expand Down Expand Up @@ -185,8 +185,8 @@ mod tests {

use bytes::Bytes;

use crate::errors::BadQuery;
use crate::test_utils::setup_tracing;
use crate::transport::errors::BadQuery;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion scylla/src/errors.rs → scylla/src/transport/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ pub(crate) enum ResponseParseError {
mod tests {
use scylla_cql::Consistency;

use crate::errors::{DbError, QueryError, WriteType};
use crate::transport::errors::{DbError, QueryError, WriteType};

#[test]
fn write_type_from_str() {
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use super::execution_profile::ExecutionProfileInner;
use super::session::RequestSpan;
use crate::cql_to_rust::{FromRow, FromRowError};

use crate::errors::{QueryError, UserRequestError};
use crate::frame::response::{
result,
result::{ColumnSpec, Row, Rows},
Expand All @@ -29,6 +28,7 @@ use crate::statement::{prepared_statement::PreparedStatement, query::Query};
use crate::statement::{Consistency, PagingState, SerialConsistency};
use crate::transport::cluster::ClusterData;
use crate::transport::connection::{Connection, NonErrorQueryResponse, QueryResponse};
use crate::transport::errors::{QueryError, UserRequestError};
use crate::transport::load_balancing::{self, RoutingInfo};
use crate::transport::metrics::Metrics;
use crate::transport::retry_policy::{QueryInfo, RetryDecision, RetrySession};
Expand Down Expand Up @@ -416,7 +416,7 @@ mod checked_channel_sender {
use tokio::sync::mpsc;
use uuid::Uuid;

use crate::errors::QueryError;
use crate::transport::errors::QueryError;

use super::ReceivedPage;

Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/large_batch_statements_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use assert_matches::assert_matches;

use crate::batch::BatchType;
use crate::errors::{BadQuery, QueryError};
use crate::query::Query;
use crate::test_utils::setup_tracing;
use crate::transport::errors::{BadQuery, QueryError};
use crate::{
batch::Batch,
test_utils::{create_new_session_builder, unique_keyspace_name},
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/load_balancing/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub use self::latency_awareness::LatencyAwarenessBuilder;

use super::{FallbackPlan, LoadBalancingPolicy, NodeRef, RoutingInfo};
use crate::{
errors::QueryError,
routing::{Shard, Token},
transport::errors::QueryError,
transport::{cluster::ClusterData, locator::ReplicaSet, node::Node, topology::Strategy},
};
use itertools::{Either, Itertools};
Expand Down Expand Up @@ -2550,9 +2550,9 @@ mod latency_awareness {
use uuid::Uuid;

use crate::{
errors::{DbError, QueryError},
load_balancing::NodeRef,
routing::Shard,
transport::errors::{DbError, QueryError},
transport::node::Node,
};
use std::{
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/load_balancing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use super::{cluster::ClusterData, NodeRef};
use crate::{
errors::QueryError,
routing::{Shard, Token},
transport::errors::QueryError,
};
use scylla_cql::frame::{response::result::TableSpec, types};

Expand Down
1 change: 1 addition & 0 deletions scylla/src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod cluster;
pub(crate) mod connection;
mod connection_pool;
pub mod downgrading_consistency_retry_policy;
pub mod errors;
pub mod execution_profile;
pub mod host_filter;
pub mod iterator;
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use tokio::net::lookup_host;
use tracing::warn;
use uuid::Uuid;

use crate::errors::{ConnectionPoolError, QueryError};
/// Node represents a cluster node along with it's data and connections
use crate::routing::{Shard, Sharder};
use crate::transport::connection::Connection;
use crate::transport::connection::VerifiedKeyspaceName;
use crate::transport::connection_pool::{NodeConnectionPool, PoolConfig};
use crate::transport::errors::{ConnectionPoolError, QueryError};

use std::fmt::Display;
use std::io;
Expand Down
6 changes: 3 additions & 3 deletions scylla/src/transport/retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//! To decide when to retry a query the `Session` can use any object which implements
//! the `RetryPolicy` trait
use crate::errors::{DbError, QueryError, WriteType};
use crate::frame::types::Consistency;
use crate::transport::errors::{DbError, QueryError, WriteType};

/// Information about a failed query
pub struct QueryInfo<'a> {
Expand Down Expand Up @@ -219,10 +219,10 @@ impl RetrySession for DefaultRetrySession {
#[cfg(test)]
mod tests {
use super::{DefaultRetryPolicy, QueryInfo, RetryDecision, RetryPolicy};
use crate::errors::{BadQuery, QueryError};
use crate::errors::{DbError, WriteType};
use crate::statement::Consistency;
use crate::test_utils::setup_tracing;
use crate::transport::errors::{BadQuery, QueryError};
use crate::transport::errors::{DbError, WriteType};
use bytes::Bytes;
use std::io::ErrorKind;
use std::sync::Arc;
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use crate::batch::batch_values;
#[cfg(feature = "cloud")]
use crate::cloud::CloudConfig;

pub use crate::errors::TranslationError;
use crate::errors::{BadQuery, NewSessionError, QueryError, UserRequestError};
use crate::history;
use crate::history::HistoryListener;
pub use crate::transport::errors::TranslationError;
use crate::transport::errors::{BadQuery, NewSessionError, QueryError, UserRequestError};
use crate::utils::pretty::{CommaSeparatedDisplayer, CqlValueDisplayer};
use arc_swap::ArcSwapOption;
use async_trait::async_trait;
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/session_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::Compression;

#[cfg(feature = "cloud")]
use crate::cloud::{CloudConfig, CloudConfigError};
use crate::errors::NewSessionError;
use crate::transport::errors::NewSessionError;
#[cfg(feature = "cloud")]
use crate::ExecutionProfile;

Expand Down
4 changes: 2 additions & 2 deletions scylla/src/transport/session_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate as scylla;
use crate::batch::{Batch, BatchStatement};
use crate::errors::{BadKeyspaceName, BadQuery, DbError, QueryError};
use crate::frame::response::result::Row;
use crate::prepared_statement::PreparedStatement;
use crate::query::Query;
Expand All @@ -10,6 +9,7 @@ use crate::statement::Consistency;
use crate::test_utils::{scylla_supports_tablets, setup_tracing};
use crate::tracing::TracingInfo;
use crate::transport::cluster::Datacenter;
use crate::transport::errors::{BadKeyspaceName, BadQuery, DbError, QueryError};
use crate::transport::partitioner::{
calculate_token_for_partition_key, Murmur3Partitioner, Partitioner, PartitionerName,
};
Expand Down Expand Up @@ -2526,7 +2526,7 @@ async fn test_rate_limit_exceeded_exception() {
}
}

use crate::errors::OperationType;
use crate::transport::errors::OperationType;

match maybe_err.expect("Rate limit error didn't occur") {
QueryError::DbError(DbError::RateLimitReached { op_type, .. }, _) => {
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/speculative_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use futures::{
use std::{future::Future, sync::Arc, time::Duration};
use tracing::{trace_span, warn, Instrument};

use crate::errors::QueryError;
use crate::transport::errors::QueryError;

use super::metrics::Metrics;

Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/topology.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::errors::{DbError, NewSessionError, QueryError};
use crate::frame::response::event::Event;
use crate::routing::Token;
use crate::statement::query::Query;
use crate::transport::connection::{Connection, ConnectionConfig};
use crate::transport::connection_pool::{NodeConnectionPool, PoolConfig, PoolSize};
use crate::transport::errors::{DbError, NewSessionError, QueryError};
use crate::transport::host_filter::HostFilter;
use crate::transport::node::resolve_contact_points;
use crate::utils::parse::{ParseErrorCause, ParseResult, ParserState};
Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/execution_profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<const NODE: u8> LoadBalancingPolicy for BoundToPredefinedNodePolicy<NODE> {
_query: &RoutingInfo,
_latency: std::time::Duration,
_node: NodeRef<'_>,
_error: &scylla::errors::QueryError,
_error: &scylla::transport::errors::QueryError,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/new_session.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::utils::setup_tracing;

use assert_matches::assert_matches;
use scylla::errors::NewSessionError;
use scylla::transport::errors::NewSessionError;
use scylla::SessionBuilder;

#[cfg(not(scylla_cloud_tests))]
Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/tablets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use scylla::ExecutionProfile;
use scylla::QueryResult;
use scylla::Session;

use scylla::errors::QueryError;
use scylla::transport::errors::QueryError;
use scylla_proxy::{
Condition, ProxyError, Reaction, ResponseFrame, ResponseOpcode, ResponseReaction, ResponseRule,
ShardAwareness, TargetShard, WorkerError,
Expand Down

0 comments on commit 043e73f

Please sign in to comment.