diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-08 00:39:07 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-08 00:39:07 +0200 |
commit | d50edcdb4f8b8ec00b1f0ffb6a3ebbb0e5afdc1f (patch) | |
tree | b283abf578b3c80c2885eb0e220f7f3a02ba994d /src/server.rs | |
parent | 90cdffb425c6222f4234db54a16c079d8c058724 (diff) | |
download | garage-d50edcdb4f8b8ec00b1f0ffb6a3ebbb0e5afdc1f.tar.gz garage-d50edcdb4f8b8ec00b1f0ffb6a3ebbb0e5afdc1f.zip |
Basic workflow for client PUT, next is do actual storage
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/server.rs b/src/server.rs index 5cac1c70..d5da8c17 100644 --- a/src/server.rs +++ b/src/server.rs @@ -4,14 +4,20 @@ use std::net::SocketAddr; use std::path::PathBuf; use futures::channel::oneshot; use serde::Deserialize; -use rand::Rng; -use crate::data::UUID; +use crate::data::*; use crate::error::Error; use crate::membership::System; use crate::api_server; use crate::rpc_server; +fn default_block_size() -> usize { + 1048576 +} +fn default_meta_replication_factor() -> usize { + 3 +} + #[derive(Deserialize, Debug)] pub struct Config { pub metadata_dir: PathBuf, @@ -21,6 +27,12 @@ pub struct Config { pub rpc_port: u16, pub bootstrap_peers: Vec<SocketAddr>, + + #[serde(default = "default_block_size")] + pub block_size: usize, + + #[serde(default = "default_meta_replication_factor")] + pub meta_replication_factor: usize, } fn read_config(config_file: PathBuf) -> Result<Config, Error> { @@ -49,11 +61,11 @@ fn gen_node_id(metadata_dir: &PathBuf) -> Result<UUID, Error> { id.copy_from_slice(&d[..]); Ok(id.into()) } else { - let id = rand::thread_rng().gen::<[u8; 32]>(); + let id = gen_uuid(); let mut f = std::fs::File::create(id_file.as_path())?; - f.write_all(&id[..])?; - Ok(id.into()) + f.write_all(id.as_slice())?; + Ok(id) } } |