mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 23:47:28 +00:00
refactor(deps): replace snafu and heal anyhow (#4266)
This commit is contained in:
Generated
+3
-26
@@ -7837,7 +7837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "0e50c72c21c738f5c5f350cc33640aee30bf7cd20f9d9da20ed41bce2671d532"
|
checksum = "0e50c72c21c738f5c5f350cc33640aee30bf7cd20f9d9da20ed41bce2671d532"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"snafu 0.6.10",
|
"snafu",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -9170,7 +9170,6 @@ dependencies = [
|
|||||||
name = "rustfs-heal"
|
name = "rustfs-heal"
|
||||||
version = "1.0.0-beta.8"
|
version = "1.0.0-beta.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures",
|
"futures",
|
||||||
"http 1.4.2",
|
"http 1.4.2",
|
||||||
@@ -9741,7 +9740,7 @@ dependencies = [
|
|||||||
"rustfs-storage-api",
|
"rustfs-storage-api",
|
||||||
"s3s",
|
"s3s",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"snafu 0.9.1",
|
"thiserror 2.0.18",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -9761,7 +9760,6 @@ dependencies = [
|
|||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rustfs-s3select-api",
|
"rustfs-s3select-api",
|
||||||
"s3s",
|
"s3s",
|
||||||
"snafu 0.9.1",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
@@ -10828,16 +10826,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7"
|
checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"doc-comment",
|
"doc-comment",
|
||||||
"snafu-derive 0.6.10",
|
"snafu-derive",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "snafu"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d1a012328be2e3f5d5f6f3218147ca02588cea4cb865e876849ab6debcf36522"
|
|
||||||
dependencies = [
|
|
||||||
"snafu-derive 0.9.1",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -10851,18 +10840,6 @@ dependencies = [
|
|||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "snafu-derive"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5f103c50866b8743da9429b8a581d81a27c2d3a9c4ac7df8f8571c1dd7896eda"
|
|
||||||
dependencies = [
|
|
||||||
"heck",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.118",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "snap"
|
name = "snap"
|
||||||
version = "1.1.1"
|
version = "1.1.1"
|
||||||
|
|||||||
@@ -289,7 +289,6 @@ shadow-rs = { version = "2.0.0", default-features = false }
|
|||||||
siphasher = "1.0.3"
|
siphasher = "1.0.3"
|
||||||
smallvec = { version = "1.15.2", features = ["serde"] }
|
smallvec = { version = "1.15.2", features = ["serde"] }
|
||||||
smartstring = "1.0.1"
|
smartstring = "1.0.1"
|
||||||
snafu = "0.9.1"
|
|
||||||
snap = "1.1.1"
|
snap = "1.1.1"
|
||||||
starshard = { version = "2.2.1", features = ["rayon", "async", "serde"] }
|
starshard = { version = "2.2.1", features = ["rayon", "async", "serde"] }
|
||||||
strum = { version = "0.28.0", features = ["derive"] }
|
strum = { version = "0.28.0", features = ["derive"] }
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ serde = { workspace = true, features = ["derive"] }
|
|||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
uuid = { workspace = true, features = ["v4", "serde"] }
|
uuid = { workspace = true, features = ["v4", "serde"] }
|
||||||
anyhow = { workspace = true }
|
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
metrics = { workspace = true }
|
metrics = { workspace = true }
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ pub enum Error {
|
|||||||
#[error("Other error: {0}")]
|
#[error("Other error: {0}")]
|
||||||
Other(String),
|
Other(String),
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Anyhow(#[from] anyhow::Error),
|
|
||||||
|
|
||||||
#[error("Serialization error: {0}")]
|
#[error("Serialization error: {0}")]
|
||||||
Serialization(String),
|
Serialization(String),
|
||||||
|
|
||||||
@@ -94,11 +91,8 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;
|
|||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
/// Create an Other error from any error type
|
/// Create an Other error from any error type
|
||||||
pub fn other<E>(error: E) -> Self
|
pub fn other(error: impl std::fmt::Display) -> Self {
|
||||||
where
|
Error::Other(error.to_string())
|
||||||
E: Into<Box<dyn std::error::Error + Send + Sync>>,
|
|
||||||
{
|
|
||||||
Error::Other(error.into().to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a transient skip error for retryable background heal checks.
|
/// Create a transient skip error for retryable background heal checks.
|
||||||
|
|||||||
@@ -588,7 +588,7 @@ fn is_recoverable_heal_error(err: &Error, error: &str) -> bool {
|
|||||||
Error::TaskTimeout | Error::TransientSkip { .. } => true,
|
Error::TaskTimeout | Error::TransientSkip { .. } => true,
|
||||||
Error::Storage(err) => is_recoverable_storage_heal_error(err) || is_recoverable_heal_error_message(error),
|
Error::Storage(err) => is_recoverable_storage_heal_error(err) || is_recoverable_heal_error_message(error),
|
||||||
Error::Disk(err) => is_recoverable_disk_heal_error(err) || is_recoverable_heal_error_message(error),
|
Error::Disk(err) => is_recoverable_disk_heal_error(err) || is_recoverable_heal_error_message(error),
|
||||||
Error::TaskExecutionFailed { .. } | Error::Io(_) | Error::IO(_) | Error::Anyhow(_) | Error::Other(_) => {
|
Error::TaskExecutionFailed { .. } | Error::Io(_) | Error::IO(_) | Error::Other(_) => {
|
||||||
is_recoverable_heal_error_message(error)
|
is_recoverable_heal_error_message(error)
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ mod storage_api;
|
|||||||
use storage_api::endpoint_index::{ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_local_disks};
|
use storage_api::endpoint_index::{ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_local_disks};
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||||
async fn test_endpoint_index_settings() -> anyhow::Result<()> {
|
async fn test_endpoint_index_settings() -> rustfs_heal::Result<()> {
|
||||||
let temp_dir = TempDir::new()?;
|
let temp_dir = TempDir::new()?;
|
||||||
|
|
||||||
// create test disk paths
|
// create test disk paths
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ http.workspace = true
|
|||||||
pin-project-lite.workspace = true
|
pin-project-lite.workspace = true
|
||||||
s3s.workspace = true
|
s3s.workspace = true
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
snafu = { workspace = true, features = ["backtrace"] }
|
thiserror = { workspace = true }
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tokio-util.workspace = true
|
tokio-util.workspace = true
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use datafusion::{common::DataFusionError, sql::sqlparser::parser::ParserError};
|
use datafusion::{common::DataFusionError, sql::sqlparser::parser::ParserError};
|
||||||
use snafu::{Backtrace, Location, Snafu};
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
pub mod object_store;
|
pub mod object_store;
|
||||||
pub mod query;
|
pub mod query;
|
||||||
@@ -31,52 +31,49 @@ pub(crate) use storage_api::crate_boundary::{
|
|||||||
select_is_err_version_not_found,
|
select_is_err_version_not_found,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Snafu)]
|
#[derive(Debug, Error)]
|
||||||
#[snafu(visibility(pub))]
|
|
||||||
pub enum QueryError {
|
pub enum QueryError {
|
||||||
#[snafu(display("DataFusion error: {}", source))]
|
#[error("DataFusion error: {source}")]
|
||||||
Datafusion {
|
Datafusion { source: Box<DataFusionError> },
|
||||||
source: Box<DataFusionError>,
|
|
||||||
location: Location,
|
|
||||||
backtrace: Backtrace,
|
|
||||||
},
|
|
||||||
|
|
||||||
#[snafu(display("This feature is not implemented: {}", err))]
|
#[error("This feature is not implemented: {err}")]
|
||||||
NotImplemented { err: String },
|
NotImplemented { err: String },
|
||||||
|
|
||||||
#[snafu(display("Multi-statement not allow, found num:{}, sql:{}", num, sql))]
|
#[error("Multi-statement not allow, found num:{num}, sql:{sql}")]
|
||||||
MultiStatement { num: usize, sql: String },
|
MultiStatement { num: usize, sql: String },
|
||||||
|
|
||||||
#[snafu(display("Failed to build QueryDispatcher. err: {}", err))]
|
#[error("Failed to build QueryDispatcher. err: {err}")]
|
||||||
BuildQueryDispatcher { err: String },
|
BuildQueryDispatcher { err: String },
|
||||||
|
|
||||||
#[snafu(display("The query has been canceled"))]
|
#[error("The query has been canceled")]
|
||||||
Cancel,
|
Cancel,
|
||||||
|
|
||||||
#[snafu(display("{}", source))]
|
#[error("{source}")]
|
||||||
Parser { source: ParserError },
|
Parser {
|
||||||
|
#[from]
|
||||||
|
source: ParserError,
|
||||||
|
},
|
||||||
|
|
||||||
#[snafu(display("Udf not exists, name:{}.", name))]
|
#[error("Udf not exists, name:{name}.")]
|
||||||
FunctionNotExists { name: String },
|
FunctionNotExists { name: String },
|
||||||
|
|
||||||
#[snafu(display("Udf already exists, name:{}.", name))]
|
#[error("Udf already exists, name:{name}.")]
|
||||||
FunctionExists { name: String },
|
FunctionExists { name: String },
|
||||||
|
|
||||||
#[snafu(display("Store Error, e:{}.", e))]
|
#[error("Store Error, e:{e}.")]
|
||||||
StoreError { e: String },
|
StoreError { e: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DataFusionError> for QueryError {
|
impl From<DataFusionError> for QueryError {
|
||||||
#[track_caller]
|
|
||||||
fn from(value: DataFusionError) -> Self {
|
fn from(value: DataFusionError) -> Self {
|
||||||
match value {
|
match value {
|
||||||
DataFusionError::External(e) if e.downcast_ref::<QueryError>().is_some() => *e.downcast::<QueryError>().unwrap(),
|
DataFusionError::External(e) => match e.downcast::<QueryError>() {
|
||||||
|
Ok(query_error) => *query_error,
|
||||||
v => Self::Datafusion {
|
Err(e) => Self::Datafusion {
|
||||||
source: Box::new(v),
|
source: Box::new(DataFusionError::External(e)),
|
||||||
location: std::panic::Location::caller(),
|
},
|
||||||
backtrace: Backtrace::capture(),
|
|
||||||
},
|
},
|
||||||
|
v => Self::Datafusion { source: Box::new(v) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ derive_builder = { workspace = true }
|
|||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
parking_lot = { workspace = true }
|
parking_lot = { workspace = true }
|
||||||
s3s.workspace = true
|
s3s.workspace = true
|
||||||
snafu = { workspace = true, features = ["backtrace"] }
|
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ use datafusion::sql::sqlparser::{
|
|||||||
tokenizer::{Token, Tokenizer},
|
tokenizer::{Token, Tokenizer},
|
||||||
};
|
};
|
||||||
use rustfs_s3select_api::{
|
use rustfs_s3select_api::{
|
||||||
ParserSnafu,
|
QueryError,
|
||||||
query::{ast::ExtStatement, parser::Parser as RustFsParser},
|
query::{ast::ExtStatement, parser::Parser as RustFsParser},
|
||||||
};
|
};
|
||||||
use snafu::ResultExt;
|
|
||||||
|
|
||||||
use super::dialect::RustFsDialect;
|
use super::dialect::RustFsDialect;
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ pub struct DefaultParser {}
|
|||||||
|
|
||||||
impl RustFsParser for DefaultParser {
|
impl RustFsParser for DefaultParser {
|
||||||
fn parse(&self, sql: &str) -> rustfs_s3select_api::QueryResult<VecDeque<ExtStatement>> {
|
fn parse(&self, sql: &str) -> rustfs_s3select_api::QueryResult<VecDeque<ExtStatement>> {
|
||||||
ExtParser::parse_sql(sql).context(ParserSnafu)
|
ExtParser::parse_sql(sql).map_err(QueryError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user