node: Make worker count configurable
This commit is contained in:
parent
6569449fff
commit
ddd4bde302
|
|
@ -49,6 +49,7 @@ $ rad config
|
||||||
"outbound": 16
|
"outbound": 16
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"workers": 8,
|
||||||
"policy": "block",
|
"policy": "block",
|
||||||
"scope": "all"
|
"scope": "all"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ impl Runtime {
|
||||||
|
|
||||||
let emitter: Emitter<Event> = Default::default();
|
let emitter: Emitter<Event> = Default::default();
|
||||||
let mut service = service::Service::new(
|
let mut service = service::Service::new(
|
||||||
config,
|
config.clone(),
|
||||||
clock,
|
clock,
|
||||||
db,
|
db,
|
||||||
storage.clone(),
|
storage.clone(),
|
||||||
|
|
@ -261,7 +261,7 @@ impl Runtime {
|
||||||
notifications,
|
notifications,
|
||||||
cobs_cache,
|
cobs_cache,
|
||||||
worker::Config {
|
worker::Config {
|
||||||
capacity: 8,
|
capacity: config.workers,
|
||||||
storage: storage.clone(),
|
storage: storage.clone(),
|
||||||
fetch,
|
fetch,
|
||||||
policy,
|
policy,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ use crate::node::{Address, Alias, NodeId};
|
||||||
|
|
||||||
/// Target number of peers to maintain connections to.
|
/// Target number of peers to maintain connections to.
|
||||||
pub const TARGET_OUTBOUND_PEERS: usize = 8;
|
pub const TARGET_OUTBOUND_PEERS: usize = 8;
|
||||||
|
/// Default number of workers to spawn.
|
||||||
|
pub const DEFAULT_WORKERS: usize = 8;
|
||||||
|
|
||||||
/// Configured public seeds.
|
/// Configured public seeds.
|
||||||
pub mod seeds {
|
pub mod seeds {
|
||||||
|
|
@ -246,6 +248,9 @@ pub struct Config {
|
||||||
/// Configured service limits.
|
/// Configured service limits.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub limits: Limits,
|
pub limits: Limits,
|
||||||
|
/// Number of worker threads to spawn.
|
||||||
|
#[serde(default = "defaults::workers")]
|
||||||
|
pub workers: usize,
|
||||||
/// Default seeding policy.
|
/// Default seeding policy.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub policy: Policy,
|
pub policy: Policy,
|
||||||
|
|
@ -272,13 +277,12 @@ impl Config {
|
||||||
network: Network::default(),
|
network: Network::default(),
|
||||||
relay: true,
|
relay: true,
|
||||||
limits: Limits::default(),
|
limits: Limits::default(),
|
||||||
|
workers: DEFAULT_WORKERS,
|
||||||
policy: Policy::default(),
|
policy: Policy::default(),
|
||||||
scope: Scope::default(),
|
scope: Scope::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Config {
|
|
||||||
pub fn peer(&self, id: &NodeId) -> Option<&Address> {
|
pub fn peer(&self, id: &NodeId) -> Option<&Address> {
|
||||||
self.connect
|
self.connect
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -294,3 +298,11 @@ impl Config {
|
||||||
node::Features::SEED
|
node::Features::SEED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defaults as functions, for serde.
|
||||||
|
mod defaults {
|
||||||
|
/// Worker count.
|
||||||
|
pub fn workers() -> usize {
|
||||||
|
super::DEFAULT_WORKERS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue