Skip to main content

expman_server/api/
state.rs

1//! Shared application state for the Axum server.
2
3use std::path::PathBuf;
4use std::sync::Arc;
5use tokio_util::sync::CancellationToken;
6
7#[derive(Clone)]
8pub struct AppState {
9    pub base_dir: Arc<PathBuf>,
10    pub jupyter: super::jupyter_service::JupyterManager,
11    pub shutdown_token: CancellationToken,
12}
13
14impl AppState {
15    pub fn new(base_dir: PathBuf) -> Self {
16        Self {
17            base_dir: Arc::new(base_dir),
18            jupyter: super::jupyter_service::JupyterManager::new(),
19            shutdown_token: CancellationToken::new(),
20        }
21    }
22}
23
24/// Configuration for the web server.
25#[derive(Debug, Clone)]
26pub struct ServerConfig {
27    pub base_dir: PathBuf,
28    pub host: String,
29    pub port: u16,
30    pub live_mode: bool,
31}
32
33impl Default for ServerConfig {
34    fn default() -> Self {
35        Self {
36            base_dir: PathBuf::from("experiments"),
37            host: "127.0.0.1".to_string(),
38            port: 8000,
39            live_mode: true,
40        }
41    }
42}