algocline_app/service/
mod.rs1mod config;
2mod eval;
3mod eval_store;
4mod logging;
5pub(crate) mod path;
6mod pkg;
7pub(crate) mod resolve;
8mod run;
9mod scenario;
10mod transcript;
11
12#[cfg(test)]
13mod tests;
14
15use std::path::Path;
16use std::sync::Arc;
17
18use algocline_engine::{Executor, SessionRegistry};
19
20pub use config::{AppConfig, LogDirSource};
21pub use resolve::QueryResponse;
22
23type EvalSessions = std::sync::Mutex<std::collections::HashMap<String, String>>;
27
28type SessionStrategies = std::sync::Mutex<std::collections::HashMap<String, String>>;
30
31#[derive(Clone)]
32pub struct AppService {
33 executor: Arc<Executor>,
34 registry: Arc<SessionRegistry>,
35 log_config: AppConfig,
36 eval_sessions: Arc<EvalSessions>,
38 session_strategies: Arc<SessionStrategies>,
40}
41
42impl AppService {
43 pub fn new(executor: Arc<Executor>, log_config: AppConfig) -> Self {
44 Self {
45 executor,
46 registry: Arc::new(SessionRegistry::new()),
47 log_config,
48 eval_sessions: Arc::new(std::sync::Mutex::new(std::collections::HashMap::new())),
49 session_strategies: Arc::new(std::sync::Mutex::new(std::collections::HashMap::new())),
50 }
51 }
52
53 fn require_log_dir(&self) -> Result<&Path, String> {
55 self.log_config
56 .log_dir
57 .as_deref()
58 .ok_or_else(|| "File logging is not available (no writable log directory)".to_string())
59 }
60}