fix: 调整init_disks位置

This commit is contained in:
shiro.lee
2024-08-05 23:06:37 +08:00
parent d73499ac79
commit 669808069d
4 changed files with 69 additions and 82 deletions
+18 -3
View File
@@ -3,8 +3,6 @@ pub mod error;
pub mod format;
mod local;
pub use local::{init_disks, DiskOption, DiskStore};
pub const RUSTFS_META_BUCKET: &str = ".rustfs.sys";
pub const RUSTFS_META_MULTIPART_BUCKET: &str = ".rustfs.sys/multipart";
pub const RUSTFS_META_TMP_BUCKET: &str = ".rustfs.sys/tmp";
@@ -19,7 +17,7 @@ use crate::{
store_api::{FileInfo, RawFileInfo},
};
use bytes::Bytes;
use std::{fmt::Debug, io::SeekFrom, pin::Pin};
use std::{fmt::Debug, io::SeekFrom, pin::Pin, sync::Arc};
use time::OffsetDateTime;
use tokio::{
fs::File,
@@ -27,6 +25,18 @@ use tokio::{
};
use uuid::Uuid;
pub type DiskStore = Arc<Box<dyn DiskAPI>>;
pub async fn new_disk(ep: &endpoint::Endpoint, opt: &DiskOption) -> Result<DiskStore> {
if ep.is_local {
let s = local::LocalDisk::new(ep, opt.cleanup).await?;
Ok(Arc::new(Box::new(s)))
} else {
let _ = opt.health_check;
unimplemented!()
}
}
#[async_trait::async_trait]
pub trait DiskAPI: Debug + Send + Sync + 'static {
fn is_local(&self) -> bool;
@@ -71,6 +81,11 @@ pub trait DiskAPI: Debug + Send + Sync + 'static {
async fn read_multiple(&self, req: ReadMultipleReq) -> Result<Vec<ReadMultipleResp>>;
}
pub struct DiskOption {
pub cleanup: bool,
pub health_check: bool,
}
pub struct RenameDataResp {
pub old_data_dir: String,
}