posemesh_compute_node/dms/
mod.rs

1//! DMS path builders and DTO shells (no HTTP).
2
3use url::Url;
4use uuid::Uuid;
5
6pub mod client;
7pub mod types;
8
9/// Helper to build DMS endpoint URLs.
10#[derive(Clone, Debug)]
11pub struct DmsPaths {
12    base: Url,
13}
14
15impl DmsPaths {
16    /// Create a new path builder from a base URL, e.g. `https://dms.example`.
17    pub fn new(base: Url) -> Self {
18        Self { base }
19    }
20
21    /// `GET/POST /tasks` — lease tasks (capability filtering via query).
22    pub fn tasks(&self) -> Url {
23        self.base.join("tasks").expect("join /tasks")
24    }
25
26    /// `GET/POST /tasks?capability=...` — lease by capability.
27    pub fn tasks_with_capability(&self, capability: &str) -> Url {
28        let mut url = self.tasks();
29        {
30            let mut qp = url.query_pairs_mut();
31            qp.append_pair("capability", capability);
32        }
33        url
34    }
35
36    /// `POST /tasks/{id}/heartbeat`
37    pub fn heartbeat(&self, task_id: Uuid) -> Url {
38        self.base
39            .join(&format!("tasks/{}/heartbeat", task_id))
40            .expect("join heartbeat")
41    }
42
43    /// `POST /tasks/{id}/complete`
44    pub fn complete(&self, task_id: Uuid) -> Url {
45        self.base
46            .join(&format!("tasks/{}/complete", task_id))
47            .expect("join complete")
48    }
49
50    /// `POST /tasks/{id}/fail`
51    pub fn fail(&self, task_id: Uuid) -> Url {
52        self.base
53            .join(&format!("tasks/{}/fail", task_id))
54            .expect("join fail")
55    }
56}