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