Skip to content

Commit

Permalink
Parralel tasks configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mersinvald committed Mar 23, 2017
1 parent eaa258f commit 019a297
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 3 additions & 0 deletions batch_resolve.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ dns = [

# Times to retry on connection timeout
retry = 5

# Number of async tasks in execution buffer
parallel_tasks = 1000
14 changes: 5 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ lazy_static! {
pub static ref CONFIG: StaticWrapper<Config> = StaticWrapper(Config::new());
}

macro_rules! uncell {
($expr:expr) => (*$expr.borrow())
}

macro_rules! uncell_mut {
($expr:expr) => (*$expr.borrow_mut())
}


#[derive(Clone, Debug)]
pub struct Config {
dns_servers: RefCell<Rc<Vec<SocketAddr>>>,
Expand Down Expand Up @@ -79,6 +70,10 @@ impl Config {
if let Some(retry) = cfg_fmt.retry {
uncell_mut!(self.timeout_retries) = retry;
}

if let Some(par_tasks) = cfg_fmt.parallel_tasks {
uncell_mut!(self.task_buffer_size) = par_tasks;
}

Ok(())
}
Expand All @@ -88,6 +83,7 @@ impl Config {
struct ConfigFormat {
dns: Option<Vec<String>>,
retry: Option<u32>,
parallel_tasks: Option<usize>,
}

#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate derive_new;
extern crate serde;
extern crate serde_yaml;
extern crate toml;

#[macro_use] extern crate log;
#[macro_use] extern crate clap;
Expand Down

0 comments on commit 019a297

Please sign in to comment.