Feeding a config object to the directory client

This commit is contained in:
Dave Hrycyszyn
2019-12-10 15:49:13 +00:00
parent e06a6f66ed
commit a2a87d72be
2 changed files with 10 additions and 3 deletions
+6 -2
View File
@@ -8,8 +8,12 @@ mod healthcheck;
mod metrics;
mod presence;
pub struct Config {
pub base_url: String,
}
pub trait DirectoryClient {
fn new(base_url: String) -> Self;
fn new(config : Config) -> Self;
fn get_topology(&self) -> Result<Topology, reqwest::Error>;
// fn send_provider_presence(&self) -> Result<ProviderPresenceResponse, reqwest::Error>;
}
@@ -17,7 +21,7 @@ pub trait DirectoryClient {
pub struct Client {}
impl DirectoryClient for Client {
fn new(base_url: String) -> Client {
fn new(config: Config) -> Client {
let topology = retrieve_topology().unwrap();
Client {}
}
+4 -1
View File
@@ -55,7 +55,10 @@ fn run(matches: &ArgMatches) {
let message = format!("Hello, Sphinx {}", i).as_bytes().to_vec();
// set up the route
let directory= directory::Client::new("https://directory.nymtech.net".to_string());
let directory_config = directory::Config {
base_url: "https://directory.nymtech.net".to_string()
};
let directory= directory::Client::new(directory_config);
// let route = directory.get_mixes();
// let destination = directory.get_destination();
let delays = sphinx::header::delays::generate(2);