-
Notifications
You must be signed in to change notification settings - Fork 2
/
showcase.rs
90 lines (72 loc) · 2.22 KB
/
showcase.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
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 conf::Conf;
use http::Uri as Url;
use std::net::SocketAddr;
/// Configuration for an http client
#[derive(Conf, Debug)]
pub struct HttpClientConfig {
/// Base URL
#[conf(long, env)]
pub url: Url,
/// Number of retries
#[conf(long, env)]
pub retries: u32,
}
/// Configuration for solver service
#[derive(Conf, Debug)]
pub struct SolveServiceConfig {
/// Listen address to bind to
#[conf(long, env, default_value = "127.0.0.1:4040")]
pub listen_addr: SocketAddr,
/// Auth service:
#[conf(flatten, prefix, help_prefix)]
pub auth: HttpClientConfig,
/// Artifact service:
#[conf(flatten, prefix, help_prefix)]
pub artifact: HttpClientConfig,
}
/// Configuration for solver algorithm
#[derive(Conf, Debug)]
pub struct SolverConfig {
/// Size of matrix to use when solving
#[conf(long, env)]
pub matrix_size: u64,
/// Branching factor to use when exploring search tree
#[conf(long, env)]
pub branching_factor: u32,
/// Epsilon which controls when we decide that solutions have stopped improving significantly
#[conf(long, env)]
pub epsilon: f64,
/// Whether to use a deterministic seeded rng
#[conf(long, env)]
pub deterministic_rng: bool,
/// Maximum number of rounds before we stop the search
#[conf(long, env)]
pub round_limit: Option<u64>,
}
/// Solves widget optimization problems on demand as a service
#[derive(Conf, Debug)]
#[conf(env_prefix = "MYCO_")]
pub struct Config {
/// Solver service:
#[conf(flatten, help_prefix)]
pub solver_service: SolveServiceConfig,
/// Basic solver:
#[conf(flatten, prefix, help_prefix)]
pub basic_solver: SolverConfig,
/// High-priority solver:
#[conf(flatten, prefix, help_prefix)]
pub high_priority_solver: SolverConfig,
/// Peers to which we can try to loadshed
#[conf(repeat, long = "peer", env)]
pub peer_urls: Vec<Url>,
/// Admin listen address to bind to
#[conf(long, env, default_value = "127.0.0.1:9090")]
pub admin_listen_addr: SocketAddr,
/// Telemetry endpoint:
#[conf(flatten, prefix, help_prefix)]
pub telemetry: HttpClientConfig,
}
fn main() {
let config = Config::parse();
println!("{config:#?}");
}