node_crunch/nc_config.rs
1//! This module contains the configuration for the server and the nodes.
2//! Usually code for the server and the node is shared.
3
4/// This data structure contains the configuration for the server and the node.
5#[derive(Debug, Clone)]
6pub struct NCConfiguration{
7 /// IP address of the server, default: 127.0.0.1
8 pub address: String,
9 /// Port used by the server, default: 9000.
10 pub port: u16,
11 /// Nodes have to send a heartbeat every n seconds or they will be marked as offline.
12 /// (The method [`heartbeat_timeout(node_id)`](crate::nc_server::NCServer::heartbeat_timeout)
13 /// with the corresponding node ID is called), default: 5.
14 pub heartbeat: u64,
15 /// Nodes will wait n seconds before contacting the server again to prevent a denial of service, default: 60.
16 pub delay_request_data: u64,
17 /// Number of times a node should try to contact the server before givin up, default: 5.
18 pub retry_counter: u64,
19 /// The number of threads in the thread pool, default: 8.
20 pub pool_size: u64,
21}
22
23impl Default for NCConfiguration {
24 fn default() -> Self {
25 NCConfiguration {
26 address: "127.0.0.1".to_string(),
27 port: 9000,
28 heartbeat: 60,
29 delay_request_data: 60,
30 retry_counter: 5,
31 pool_size: 8
32 }
33 }
34}