-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
lib.rs
46 lines (42 loc) · 1.03 KB
/
lib.rs
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
pub mod plumber;
pub mod start;
pub use plumber::*;
pub use start::*;
#[cfg(feature = "rlib")]
use extendr_api::prelude::*;
#[cfg(feature = "rlib")]
#[extendr]
pub fn valve_run_(
filepath: String,
host: String,
port: u16,
workers: u16,
n_max: u16,
check_interval: i32,
max_age: i32,
) {
let workers = workers as usize;
let n_max = n_max as usize;
tokio::runtime::Builder::new_multi_thread()
.worker_threads(workers)
.enable_all()
.build()
.unwrap()
.block_on(async {
tokio::select! {
_ = valve_start(filepath, host, port, n_max, check_interval, max_age) => {
}
r = tokio::signal::ctrl_c() => {
match r {
Ok(()) => {/* cancelled */}
Err(e) => eprintln!("Unable to listen for shutdown signal: {e}"),
}
}
};
});
}
#[cfg(feature = "rlib")]
extendr_module! {
mod valve;
fn valve_run_;
}