mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-07 22:03:14 +00:00
run init
This commit is contained in:
@@ -1 +1,74 @@
|
||||
// use s3s::S3Error;
|
||||
// use s3s::S3ErrorCode;
|
||||
|
||||
use std::panic::Location;
|
||||
|
||||
use tracing::error;
|
||||
|
||||
pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
source: StdError,
|
||||
}
|
||||
|
||||
pub type Result<T = (), E = Error> = std::result::Result<T, E>;
|
||||
|
||||
impl Error {
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub fn new(source: StdError) -> Self {
|
||||
log(&*source);
|
||||
Self { source }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub fn from_string(s: impl Into<String>) -> Self {
|
||||
Self::new(s.into().into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E> From<E> for Error
|
||||
where
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
{
|
||||
#[track_caller]
|
||||
fn from(source: E) -> Self {
|
||||
Self::new(Box::new(source))
|
||||
}
|
||||
}
|
||||
|
||||
// impl From<Error> for S3Error {
|
||||
// fn from(e: Error) -> Self {
|
||||
// S3Error::with_source(S3ErrorCode::InternalError, e.source)
|
||||
// }
|
||||
// }
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub(crate) fn log(source: &dyn std::error::Error) {
|
||||
if cfg!(feature = "binary") {
|
||||
let location = Location::caller();
|
||||
let span_trace = tracing_error::SpanTrace::capture();
|
||||
|
||||
error!(
|
||||
target: "s3s_fs_internal_error",
|
||||
%location,
|
||||
error=%source,
|
||||
"span trace:\n{span_trace}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! try_ {
|
||||
($result:expr) => {
|
||||
match $result {
|
||||
Ok(val) => val,
|
||||
Err(err) => {
|
||||
$crate::error::log(&err);
|
||||
return Err(::s3s::S3Error::internal_error(err));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ mod disks_layout;
|
||||
mod ellipses;
|
||||
mod endpoint;
|
||||
mod erasure;
|
||||
mod error;
|
||||
pub mod error;
|
||||
pub mod s3;
|
||||
pub mod store;
|
||||
mod stream;
|
||||
|
||||
+10
-4
@@ -1,19 +1,25 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::endpoint::Endpoint;
|
||||
use crate::endpoint::EndpointServerPools;
|
||||
use super::error::Result;
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ECStore {
|
||||
pub id: uuid::Uuid,
|
||||
pub disks: Vec<Box<dyn DiskAPI>>,
|
||||
// pub disks: Vec<Box<dyn DiskAPI>>,
|
||||
pub pools: Vec<Sets>,
|
||||
pub peer: Vec<String>,
|
||||
}
|
||||
|
||||
impl ECStore {
|
||||
pub fn new(endpoints: EndpointServerPools) {
|
||||
unimplemented!()
|
||||
pub fn new(endpoints: Vec<String>) -> Result<Self> {
|
||||
Ok(ECStore {
|
||||
id: Uuid::nil(),
|
||||
pools: Vec::new(),
|
||||
peer: Vec::new(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user