hyperstack_server/
config.rs1use std::net::SocketAddr;
2
3pub use crate::health::HealthConfig;
4pub use crate::http_health::HttpHealthConfig;
5
6#[derive(Clone, Debug)]
8pub struct WebSocketConfig {
9 pub bind_address: SocketAddr,
10}
11
12impl Default for WebSocketConfig {
13 fn default() -> Self {
14 Self {
15 bind_address: "[::]:8877".parse().expect("valid socket address"),
16 }
17 }
18}
19
20impl WebSocketConfig {
21 pub fn new(bind_address: impl Into<SocketAddr>) -> Self {
22 Self {
23 bind_address: bind_address.into(),
24 }
25 }
26}
27
28#[derive(Clone, Debug)]
30pub struct YellowstoneConfig {
31 pub endpoint: String,
32 pub x_token: Option<String>,
33}
34
35impl YellowstoneConfig {
36 pub fn new(endpoint: impl Into<String>) -> Self {
37 Self {
38 endpoint: endpoint.into(),
39 x_token: None,
40 }
41 }
42
43 pub fn with_token(mut self, token: impl Into<String>) -> Self {
44 self.x_token = Some(token.into());
45 self
46 }
47}
48
49#[derive(Clone, Debug, Default)]
51pub struct ServerConfig {
52 pub websocket: Option<WebSocketConfig>,
53 pub yellowstone: Option<YellowstoneConfig>,
54 pub health: Option<HealthConfig>,
55 pub http_health: Option<HttpHealthConfig>,
56}
57
58impl ServerConfig {
59 pub fn new() -> Self {
60 Self::default()
61 }
62
63 pub fn with_websocket(mut self, config: WebSocketConfig) -> Self {
64 self.websocket = Some(config);
65 self
66 }
67
68 pub fn with_yellowstone(mut self, config: YellowstoneConfig) -> Self {
69 self.yellowstone = Some(config);
70 self
71 }
72
73 pub fn with_health(mut self, config: HealthConfig) -> Self {
74 self.health = Some(config);
75 self
76 }
77
78 pub fn with_http_health(mut self, config: HttpHealthConfig) -> Self {
79 self.http_health = Some(config);
80 self
81 }
82}