amalgam_daemon/
lib.rs

1//! Runtime daemon for watching and regenerating types
2
3use anyhow::Result;
4use std::path::PathBuf;
5use tracing::info;
6
7pub struct Daemon {
8    watch_paths: Vec<PathBuf>,
9    output_dir: PathBuf,
10}
11
12impl Daemon {
13    pub fn new(output_dir: PathBuf) -> Self {
14        Self {
15            watch_paths: Vec::new(),
16            output_dir,
17        }
18    }
19
20    pub fn add_watch_path(&mut self, path: PathBuf) {
21        self.watch_paths.push(path);
22    }
23
24    pub async fn run(&self) -> Result<()> {
25        info!("Starting amalgam daemon");
26        info!("Watching paths: {:?}", self.watch_paths);
27        info!("Output directory: {:?}", self.output_dir);
28
29        // TODO: Implement file watching
30        // TODO: Implement incremental compilation
31        // TODO: Implement caching
32
33        Ok(())
34    }
35}
36
37#[cfg(feature = "kubernetes")]
38pub mod k8s {
39    use super::*;
40    use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition;
41    use kube::{Api, Client};
42
43    pub struct K8sWatcher {
44        client: Client,
45    }
46
47    impl K8sWatcher {
48        pub async fn new() -> Result<Self> {
49            let client = Client::try_default().await?;
50            Ok(Self { client })
51        }
52
53        pub async fn watch_crds(&self) -> Result<()> {
54            let crds: Api<CustomResourceDefinition> = Api::all(self.client.clone());
55
56            // TODO: Implement CRD watching
57            // TODO: Generate types when CRDs change
58
59            Ok(())
60        }
61    }
62}