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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
use std::sync::Arc;
use crate::init_logging;
use crate::platform::Platform;
const JUPITER_VERSION: &'static str = "DEVELOPMENT-SNAPSHOT";
const JUPITER_REVISION: &'static str = "NO-REVISION";
pub struct Builder {
versions: Versions,
setup_logging: bool,
enable_signals: bool,
ping_command: bool,
core_commands: bool,
setup_config: bool,
setup_commands: bool,
setup_server: bool,
}
pub struct Versions {
pub platform_version: &'static str,
pub platform_revision: &'static str,
pub product_name: &'static str,
pub product_version: &'static str,
pub product_revision: &'static str,
}
impl Builder {
pub fn new(
product_name: &'static str,
product_version: &'static str,
product_revision: &'static str,
) -> Self {
Builder {
versions: Versions {
platform_version: JUPITER_VERSION,
platform_revision: JUPITER_REVISION,
product_name,
product_version,
product_revision,
},
setup_logging: false,
enable_signals: false,
ping_command: false,
core_commands: false,
setup_config: false,
setup_commands: false,
setup_server: false,
}
}
pub fn enable_all(mut self) -> Self {
self.setup_logging = true;
self.enable_signals = true;
self.ping_command = true;
self.core_commands = true;
self.setup_config = true;
self.setup_commands = true;
self.setup_server = true;
self
}
pub fn enable_logging(mut self) -> Self {
self.setup_logging = true;
self
}
pub fn disable_logging(mut self) -> Self {
self.setup_logging = false;
self
}
pub fn enable_signals(mut self) -> Self {
self.enable_signals = true;
self
}
pub fn disable_signals(mut self) -> Self {
self.enable_signals = false;
self
}
pub fn enable_ping_command(mut self) -> Self {
self.ping_command = true;
self
}
pub fn disable_ping_command(mut self) -> Self {
self.ping_command = false;
self
}
pub fn enable_core_commands(mut self) -> Self {
self.core_commands = true;
self
}
pub fn disable_core_commands(mut self) -> Self {
self.core_commands = false;
self
}
pub fn enable_config(mut self) -> Self {
self.setup_config = true;
self
}
pub fn disable_config(mut self) -> Self {
self.setup_config = false;
self
}
pub fn enable_commands(mut self) -> Self {
self.setup_commands = true;
self
}
pub fn disable_commands(mut self) -> Self {
self.setup_commands = false;
self
}
pub fn enable_server(mut self) -> Self {
self.setup_server = true;
self
}
pub fn disable_server(mut self) -> Self {
self.setup_server = false;
self
}
pub fn build(self) -> Arc<Platform> {
let platform = Platform::new();
if self.setup_logging {
init_logging();
}
log::info!(
"||. JUPITER (v {} - rev {}) running on {} core(s) in {} CPU(s)",
self.versions.platform_version,
self.versions.platform_revision,
num_cpus::get(),
num_cpus::get_physical()
);
log::info!(
"--> {} (v {} - rev {}) is being initialized...",
self.versions.product_name,
self.versions.product_version,
self.versions.product_revision
);
platform.register::<Versions>(Arc::new(self.versions));
if self.enable_signals {
crate::signals::install(platform.clone());
}
if self.setup_commands {
crate::commands::CommandDictionary::install(&platform);
if self.ping_command {
crate::ping::install(&platform);
}
if self.core_commands {}
}
if self.setup_config {
crate::config::install(platform.clone());
}
if self.setup_server {
crate::server::Server::install(&platform);
}
platform
}
}