reifydb_sub_server_admin/
config.rs1use std::{fmt, time::Duration};
7
8use reifydb_runtime::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 fmt::Debug for AdminConfig {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> 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 .finish()
36 }
37}
38
39impl Default for AdminConfig {
40 fn default() -> Self {
41 Self {
42 bind_addr: "127.0.0.1:9090".to_string(),
43 max_connections: 1_000,
44 request_timeout: Duration::from_secs(30),
45 auth_required: false,
46 auth_token: None,
47 runtime: None,
48 }
49 }
50}
51
52impl AdminConfig {
53 pub fn new() -> Self {
55 Self::default()
56 }
57
58 pub fn bind_addr(mut self, addr: impl Into<String>) -> Self {
60 self.bind_addr = addr.into();
61 self
62 }
63
64 pub fn max_connections(mut self, max: usize) -> Self {
66 self.max_connections = max;
67 self
68 }
69
70 pub fn request_timeout(mut self, timeout: Duration) -> Self {
72 self.request_timeout = timeout;
73 self
74 }
75
76 pub fn with_auth(mut self, token: String) -> Self {
78 self.auth_required = true;
79 self.auth_token = Some(token);
80 self
81 }
82
83 pub fn runtime(mut self, runtime: SharedRuntime) -> Self {
85 self.runtime = Some(runtime);
86 self
87 }
88}