init:store

This commit is contained in:
weisd
2024-06-26 15:53:11 +08:00
parent 918a263fd0
commit 03572ebcab
8 changed files with 586 additions and 12 deletions
+35 -6
View File
@@ -1,9 +1,14 @@
use uuid::Uuid;
use crate::{disks_layout::DisksLayout, endpoint::create_server_endpoints};
use crate::{
disk::{self, DiskAPI, DiskOption},
disks_layout::DisksLayout,
endpoint::create_server_endpoints,
format::FormatV3,
};
use super::endpoint::Endpoint;
use anyhow::Result;
use anyhow::{Error, Result};
use std::fmt::Debug;
@@ -16,10 +21,20 @@ pub struct ECStore {
}
impl ECStore {
pub fn new(address: String, endpoints: Vec<String>) -> Result<Self> {
pub async fn new(address: String, endpoints: Vec<String>) -> Result<Self> {
let layouts = DisksLayout::new(endpoints)?;
let (pools, _) = create_server_endpoints(address, &layouts.pools, layouts.legacy)?;
for (i, pool_eps) in pools.iter().enumerate() {
let (disks, errs) = disk::init_disks(
&pool_eps.endpoints,
&DiskOption {
cleanup: true,
health_check: true,
},
)
.await;
}
Ok(ECStore {
id: Uuid::nil(),
@@ -27,6 +42,23 @@ impl ECStore {
peer: Vec::new(),
})
}
async fn load_formats(
disks: Vec<Option<impl DiskAPI>>,
heal: bool,
) -> (Vec<FormatV3>, Vec<Error>) {
unimplemented!()
}
fn default_partiy_blocks(drive: usize) -> usize {
match drive {
1 => 0,
2 | 3 => 1,
4 | 5 => 2,
6 | 7 => 3,
_ => 4,
}
}
}
#[derive(Debug)]
@@ -44,7 +76,4 @@ pub struct Objects {
pub default_parity_count: usize,
}
#[async_trait::async_trait]
trait DiskAPI: Debug + Send + Sync + 'static {}
pub trait StorageAPI: Debug + Send + Sync + 'static {}