algocline_app/service/
mod.rs1mod config;
2mod engine_api_impl;
3mod eval;
4mod eval_store;
5mod logging;
6pub(crate) mod manifest;
7pub(crate) mod path;
8mod pkg;
9pub mod resolve;
10mod run;
11mod scenario;
12mod status;
13mod transcript;
14
15#[cfg(test)]
16mod tests;
17
18use std::path::Path;
19use std::sync::Arc;
20
21use algocline_engine::{Executor, SessionRegistry};
22
23pub use algocline_core::{EngineApi, TokenUsage};
24pub use config::{AppConfig, LogDirSource};
25pub use resolve::{QueryResponse, SearchPath};
26
27type EvalSessions = std::sync::Mutex<std::collections::HashMap<String, String>>;
37
38type SessionStrategies = std::sync::Mutex<std::collections::HashMap<String, String>>;
44
45#[derive(Clone)]
46pub struct AppService {
47 executor: Arc<Executor>,
48 registry: Arc<SessionRegistry>,
49 log_config: AppConfig,
50 search_paths: Vec<resolve::SearchPath>,
52 eval_sessions: Arc<EvalSessions>,
54 session_strategies: Arc<SessionStrategies>,
56}
57
58impl AppService {
59 pub fn new(
60 executor: Arc<Executor>,
61 log_config: AppConfig,
62 search_paths: Vec<resolve::SearchPath>,
63 ) -> Self {
64 let registry = Arc::new(SessionRegistry::new());
65 registry.spawn_gc_task(std::time::Duration::from_secs(10800));
68 Self {
69 executor,
70 registry,
71 log_config,
72 search_paths,
73 eval_sessions: Arc::new(std::sync::Mutex::new(std::collections::HashMap::new())),
74 session_strategies: Arc::new(std::sync::Mutex::new(std::collections::HashMap::new())),
75 }
76 }
77
78 fn require_log_dir(&self) -> Result<&Path, String> {
80 self.log_config
81 .log_dir
82 .as_deref()
83 .ok_or_else(|| "File logging is not available (no writable log directory)".to_string())
84 }
85}