algocline_app/service/
mod.rs1mod config;
2mod eval;
3mod eval_store;
4mod logging;
5pub(crate) mod path;
6mod pkg;
7pub mod resolve;
8mod run;
9mod scenario;
10mod status;
11mod transcript;
12
13#[cfg(test)]
14mod tests;
15
16use std::path::Path;
17use std::sync::Arc;
18
19use algocline_engine::{Executor, SessionRegistry};
20
21pub use config::{AppConfig, LogDirSource};
22pub use resolve::{QueryResponse, SearchPath};
23
24type EvalSessions = std::sync::Mutex<std::collections::HashMap<String, String>>;
34
35type SessionStrategies = std::sync::Mutex<std::collections::HashMap<String, String>>;
41
42#[derive(Clone)]
43pub struct AppService {
44 executor: Arc<Executor>,
45 registry: Arc<SessionRegistry>,
46 log_config: AppConfig,
47 search_paths: Vec<resolve::SearchPath>,
49 eval_sessions: Arc<EvalSessions>,
51 session_strategies: Arc<SessionStrategies>,
53}
54
55impl AppService {
56 pub fn new(
57 executor: Arc<Executor>,
58 log_config: AppConfig,
59 search_paths: Vec<resolve::SearchPath>,
60 ) -> Self {
61 Self {
62 executor,
63 registry: Arc::new(SessionRegistry::new()),
64 log_config,
65 search_paths,
66 eval_sessions: Arc::new(std::sync::Mutex::new(std::collections::HashMap::new())),
67 session_strategies: Arc::new(std::sync::Mutex::new(std::collections::HashMap::new())),
68 }
69 }
70
71 fn require_log_dir(&self) -> Result<&Path, String> {
73 self.log_config
74 .log_dir
75 .as_deref()
76 .ok_or_else(|| "File logging is not available (no writable log directory)".to_string())
77 }
78}