Skip to content

Commit

Permalink
metadata: replace remaining QueryError occurrences in the module
Browse files Browse the repository at this point in the history
  • Loading branch information
muzarski committed Jan 24, 2025
1 parent 3baa0b8 commit f76d0b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scylla/src/cluster/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::client::pager::{NextPageError, NextRowError, QueryPager};
use crate::cluster::node::resolve_contact_points;
use crate::deserialize::DeserializeOwnedRow;
use crate::errors::{DbError, NewSessionError, QueryError, RequestAttemptError};
use crate::errors::{DbError, NewSessionError, RequestAttemptError};
use crate::frame::response::event::Event;
use crate::network::{Connection, ConnectionConfig, NodeConnectionPool, PoolConfig, PoolSize};
use crate::policies::host_filter::HostFilter;
Expand Down Expand Up @@ -542,7 +542,7 @@ impl MetadataReader {
}

/// Fetches current metadata from the cluster
pub(crate) async fn read_metadata(&mut self, initial: bool) -> Result<Metadata, QueryError> {
pub(crate) async fn read_metadata(&mut self, initial: bool) -> Result<Metadata, MetadataError> {
let mut result = self.fetch_metadata(initial).await;
let prev_err = match result {
Ok(metadata) => {
Expand Down Expand Up @@ -620,8 +620,8 @@ impl MetadataReader {
&mut self,
initial: bool,
nodes: impl Iterator<Item = UntranslatedEndpoint>,
prev_err: QueryError,
) -> Result<Metadata, QueryError> {
prev_err: MetadataError,
) -> Result<Metadata, MetadataError> {
let mut result = Err(prev_err);
for peer in nodes {
let err = match result {
Expand Down Expand Up @@ -654,7 +654,7 @@ impl MetadataReader {
result
}

async fn fetch_metadata(&self, initial: bool) -> Result<Metadata, QueryError> {
async fn fetch_metadata(&self, initial: bool) -> Result<Metadata, MetadataError> {
// TODO: Timeouts?
self.control_connection.wait_until_initialized().await;
let conn = &self.control_connection.random_connection()?;
Expand All @@ -680,7 +680,7 @@ impl MetadataReader {
}
}

res.map_err(QueryError::MetadataError)
res
}

fn update_known_peers(&mut self, metadata: &Metadata) {
Expand Down
4 changes: 4 additions & 0 deletions scylla/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ pub enum TracingProtocolError {
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum MetadataError {
/// Control connection pool error.
#[error("Control connection pool error: {0}")]
ConnectionPoolError(#[from] ConnectionPoolError),

/// Bad peers metadata.
#[error("Bad peers metadata: {0}")]
Peers(#[from] PeersMetadataError),
Expand Down

0 comments on commit f76d0b8

Please sign in to comment.