reifydb_sub_server_admin/
config.rs1use std::time::Duration;
7
8use reifydb_sub_server::SharedRuntime;
9
10#[derive(Clone)]
12pub struct AdminConfig {
13 pub bind_addr: String,
15 pub max_connections: usize,
17 pub request_timeout: Duration,
19 pub auth_required: bool,
21 pub auth_token: Option<String>,
23 pub runtime: Option<SharedRuntime>,
25}
26
27impl std::fmt::Debug for AdminConfig {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 f.debug_struct("AdminConfig")
30 .field("bind_addr", &self.bind_addr)
31 .field("max_connections", &self.max_connections)
32 .field("request_timeout", &self.request_timeout)
33 .field("auth_required", &self.auth_required)
34 .field("auth_token", &self.auth_token.as_ref().map(|_| "****"))
35 .field("runtime", &self.runtime.as_ref().map(|_| "SharedRuntime"))
36 .finish()
37 }
38}
39
40impl Default for AdminConfig {
41 fn default() -> Self {
42 Self {
43 bind_addr: "127.0.0.1:9090".to_string(),
44 max_connections: 1_000,
45 request_timeout: Duration::from_secs(30),
46 auth_required: false,
47 auth_token: None,
48 runtime: None,
49 }
50 }
51}
52
53impl AdminConfig {
54 pub fn new() -> Self {
56 Self::default()
57 }
58
59 pub fn bind_addr(mut self, addr: impl Into<String>) -> Self {
61 self.bind_addr = addr.into();
62 self
63 }
64
65 pub fn max_connections(mut self, max: usize) -> Self {
67 self.max_connections = max;
68 self
69 }
70
71 pub fn request_timeout(mut self, timeout: Duration) -> Self {
73 self.request_timeout = timeout;
74 self
75 }
76
77 pub fn with_auth(mut self, token: String) -> Self {
79 self.auth_required = true;
80 self.auth_token = Some(token);
81 self
82 }
83
84 pub fn runtime(mut self, runtime: SharedRuntime) -> Self {
86 self.runtime = Some(runtime);
87 self
88 }
89}