Skip to content

Commit 8cc2518

Browse files
committed
Reworked config to pass some of the clap parameters
1 parent 2cbfc40 commit 8cc2518

File tree

4 files changed

+117
-164
lines changed

4 files changed

+117
-164
lines changed

mithril-aggregator/src/entities.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::snapshot_uploaders::SnapshotUploader;
44
use crate::tools::GcpFileUploader;
55
use crate::{LocalSnapshotUploader, RemoteSnapshotStore, RemoteSnapshotUploader};
66
use serde::{Deserialize, Serialize};
7+
use std::path::PathBuf;
78
use std::sync::Arc;
89
use tokio::sync::RwLock;
910

@@ -21,6 +22,15 @@ pub struct Config {
2122

2223
/// Type of snapshot uploader to use
2324
pub snapshot_uploader_type: SnapshotUploaderType,
25+
26+
/// Server listening IP
27+
pub server_url: String,
28+
29+
/// Directory to snapshot
30+
pub db_directory: PathBuf,
31+
32+
/// Directory to store snapshot
33+
pub snapshot_directory: PathBuf,
2434
}
2535

2636
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@@ -48,19 +58,14 @@ impl Config {
4858
}
4959
}
5060

51-
pub fn build_snapshot_uploader(
52-
&self,
53-
snapshot_server_url: String,
54-
snapshot_server_port: u16,
55-
) -> Box<dyn SnapshotUploader> {
61+
pub fn build_snapshot_uploader(&self) -> Box<dyn SnapshotUploader> {
5662
match self.snapshot_store_type {
5763
SnapshotStoreType::Gcp => Box::new(RemoteSnapshotUploader::new(Box::new(
5864
GcpFileUploader::default(),
5965
))),
60-
SnapshotStoreType::Local => Box::new(LocalSnapshotUploader::new(
61-
snapshot_server_url,
62-
snapshot_server_port,
63-
)),
66+
SnapshotStoreType::Local => {
67+
Box::new(LocalSnapshotUploader::new(self.server_url.clone()))
68+
}
6469
}
6570
}
6671
}

0 commit comments

Comments
 (0)