1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use std::net::SocketAddr;
use clap::Clap;
use dvm_net::endpoint::Endpoint;
#[derive(Debug, Default, Clone, Clap)]
pub struct InfoServiceConfig {
#[clap(
name = "info service listen address. HOST_ADDRESS:PORT",
env = "INFO_SERVICE_ADDR",
long = "info-service-addr",
short = 'i',
verbatim_doc_comment
)]
pub info_service_addr: Option<SocketAddr>,
#[clap(
name = "Dvm self check address. protocol://HOST_ADDRESS:PORT",
env = "DVM_SELF_CHECK_ADDRESS",
long = "dvm-self-check-addr",
verbatim_doc_comment
)]
pub dvm_self_check_addr: Option<Endpoint>,
#[clap(
default_value = "5",
env = "METRIC_UPDATE_INTERVAL",
name = "seconds between updates",
long = "metric-update-interval",
verbatim_doc_comment
)]
pub metric_update_interval: u64,
#[clap(
default_value = "5",
env = "HEARTBEAT_INTERVAL_MAX",
name = "max seconds between heartbeats",
long = "heartbeat-interval-max",
verbatim_doc_comment
)]
pub heartbeat_max_interval: u64,
#[clap(
default_value = "4",
env = "HEARTBEAT_PRESSURE",
name = "seconds between heartbeats",
long = "heartbeat-pressure",
verbatim_doc_comment
)]
pub heartbeat_stimulation_interval: u64,
}
#[derive(Debug, Default, Clone, Clap)]
pub struct MemoryOptions {
#[clap(
default_value = "102400",
long = "module_cache_size",
verbatim_doc_comment
)]
pub module_cache: usize,
#[clap(
default_value = "1000",
long = "vm_reset_interval",
verbatim_doc_comment
)]
pub vm_reset_interval: usize,
}
impl MemoryOptions {
pub fn module_cache(&self) -> usize {
self.module_cache * 1024
}
pub fn memory_check_period(&self) -> usize {
self.vm_reset_interval
}
}