posemesh_compute_node/dms/
mod.rs1use url::Url;
4use uuid::Uuid;
5
6pub mod client;
7pub mod types;
8
9#[derive(Clone, Debug)]
11pub struct DmsPaths {
12 base: Url,
13}
14
15impl DmsPaths {
16 pub fn new(base: Url) -> Self {
18 Self { base }
19 }
20
21 pub fn tasks(&self) -> Url {
23 self.base.join("tasks").expect("join /tasks")
24 }
25
26 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 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 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 pub fn fail(&self, task_id: Uuid) -> Url {
52 self.base
53 .join(&format!("tasks/{}/fail", task_id))
54 .expect("join fail")
55 }
56}