service/config.rs
1use std::{
2 net::{IpAddr, Ipv4Addr, SocketAddr},
3 path::PathBuf,
4};
5
6use common::prelude::SecretKey;
7
8#[derive(Debug)]
9pub struct Config {
10 // peer configuration
11 /// address for our jax peer to listen on,
12 /// if not set then an ephemeral port will be used
13 pub node_listen_addr: Option<SocketAddr>,
14 /// on system file path to our secret,
15 /// if not set then a new secret will be generated
16 pub node_secret: Option<SecretKey>,
17 /// the path to our blobs store, if not set then
18 /// a temporary directory will be used
19 pub node_blobs_store_path: Option<PathBuf>,
20
21 // http server configuration
22 /// address for the HTML server to listen on.
23 /// if not set then 0.0.0.0:8080 will be used
24 pub html_listen_addr: Option<SocketAddr>,
25 /// address for the API server to listen on.
26 /// if not set then 0.0.0.0:3000 will be used
27 pub api_listen_addr: Option<SocketAddr>,
28
29 // data store configuration
30 /// a path to a sqlite database, if not set then an
31 /// in-memory database will be used
32 pub sqlite_path: Option<PathBuf>,
33
34 // misc
35 pub log_level: tracing::Level,
36
37 // ui configuration
38 /// run the HTML UI in read-only mode (hides write operations)
39 pub ui_read_only: bool,
40 /// API hostname to use for HTML UI
41 pub api_hostname: Option<String>,
42}
43
44impl Default for Config {
45 fn default() -> Self {
46 Self {
47 node_listen_addr: None,
48 node_secret: None,
49 node_blobs_store_path: None,
50 html_listen_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8080)),
51 api_listen_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 3000)),
52 sqlite_path: None,
53 log_level: tracing::Level::INFO,
54 ui_read_only: false,
55 api_hostname: None,
56 }
57 }
58}
59
60// TODO (amiller68): real error handling
61#[allow(dead_code)]
62#[derive(Debug, thiserror::Error)]
63pub enum ConfigError {}