mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
run init
This commit is contained in:
@@ -12,8 +12,6 @@ pub struct Error {
|
||||
source: StdError,
|
||||
}
|
||||
|
||||
pub type Result<T = (), E = Error> = std::result::Result<T, E>;
|
||||
|
||||
impl Error {
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
|
||||
@@ -3,7 +3,6 @@ mod ellipses;
|
||||
mod endpoint;
|
||||
mod erasure;
|
||||
pub mod error;
|
||||
pub mod s3;
|
||||
pub mod store;
|
||||
mod stream;
|
||||
mod utils;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{disks_layout::DisksLayout, endpoint::create_server_endpoints};
|
||||
|
||||
use super::endpoint::Endpoint;
|
||||
use super::error::Result;
|
||||
use anyhow::Result;
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
@@ -14,7 +16,11 @@ pub struct ECStore {
|
||||
}
|
||||
|
||||
impl ECStore {
|
||||
pub fn new(endpoints: Vec<String>) -> Result<Self> {
|
||||
pub fn new(endpoints: Vec<String>, address: String) -> Result<Self> {
|
||||
let layouts = DisksLayout::new(endpoints)?;
|
||||
|
||||
let (pools, _) = create_server_endpoints(address, &layouts.pools, layouts.legacy)?;
|
||||
|
||||
Ok(ECStore {
|
||||
id: Uuid::nil(),
|
||||
pools: Vec::new(),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use clap::Parser;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Default port that a rustfs server listens on.
|
||||
///
|
||||
@@ -10,10 +9,10 @@ pub const DEFAULT_PORT: u16 = 9000;
|
||||
pub struct Opt {
|
||||
/// DIR points to a directory on a filesystem.
|
||||
#[arg(required = true)]
|
||||
pub volumes: Vec<PathBuf>,
|
||||
pub volumes: Vec<String>,
|
||||
|
||||
/// bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname
|
||||
#[arg(long, default_value_t = format!(":{}", DEFAULT_PORT))]
|
||||
#[arg(long, default_value_t = format!("0.0.0.0:{}", DEFAULT_PORT))]
|
||||
pub address: String,
|
||||
|
||||
/// Access key used for authentication.
|
||||
|
||||
@@ -3,6 +3,7 @@ mod storage;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use ecstore::store::ECStore;
|
||||
use hyper_util::{
|
||||
rt::{TokioExecutor, TokioIo},
|
||||
server::conn::auto::Builder as ConnBuilder,
|
||||
@@ -10,7 +11,7 @@ use hyper_util::{
|
||||
use s3s::{auth::SimpleAuth, service::S3ServiceBuilder};
|
||||
use std::io::IsTerminal;
|
||||
use tokio::net::TcpListener;
|
||||
use tracing::info;
|
||||
use tracing::{debug, info};
|
||||
|
||||
fn setup_tracing() {
|
||||
use tracing_subscriber::EnvFilter;
|
||||
@@ -35,9 +36,10 @@ fn main() -> Result<()> {
|
||||
|
||||
#[tokio::main]
|
||||
async fn run(opt: config::Opt) -> Result<()> {
|
||||
debug!("opt: {:?}", &opt);
|
||||
// Setup S3 service
|
||||
let service = {
|
||||
let mut b = S3ServiceBuilder::new(storage::SimpleFS {});
|
||||
let mut b = S3ServiceBuilder::new(storage::ecfs::EC::new(opt.volumes)?);
|
||||
|
||||
// Enable authentication
|
||||
if let (Some(ak), Some(sk)) = (opt.access_key, opt.secret_key) {
|
||||
|
||||
@@ -4,10 +4,23 @@ use s3s::S3Result;
|
||||
use s3s::S3;
|
||||
use s3s::{S3Request, S3Response};
|
||||
|
||||
use crate::store::ECStore;
|
||||
use anyhow::Result;
|
||||
use ecstore::store::ECStore;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EC {
|
||||
store: ECStore,
|
||||
}
|
||||
|
||||
impl EC {
|
||||
pub fn new(endpoints: Vec<String>) -> Result<Self> {
|
||||
let store = ECStore::new(endpoints)?;
|
||||
Ok(EC { store })
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl S3 for ECStore {
|
||||
impl S3 for EC {
|
||||
#[tracing::instrument]
|
||||
async fn create_bucket(
|
||||
&self,
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod ecfs;
|
||||
mod simple_fs;
|
||||
|
||||
pub use simple_fs::SimpleFS;
|
||||
|
||||
@@ -10,9 +10,8 @@ if [ -z "$RUST_LOG" ]; then
|
||||
fi
|
||||
|
||||
cargo run \
|
||||
-- --access-key AKEXAMPLERUSTFS \
|
||||
-- --secret-key SKEXAMPLERUSTFS \
|
||||
-- --host localhost \
|
||||
-- --port 9010 \
|
||||
-- --domain-name localhost:9010 \
|
||||
-- --access-key AKEXAMPLERUSTFS \
|
||||
--secret-key SKEXAMPLERUSTFS \
|
||||
--address 0.0.0.0:9010 \
|
||||
--domain-name localhost:9010 \
|
||||
"$DATA_DIR"
|
||||
|
||||
Reference in New Issue
Block a user