Skip to main content

assay_workflow/
namespaces.rs

1//! Namespace CRUD + snapshot methods.
2
3use anyhow::Result;
4
5use crate::ctx::WorkflowCtx;
6use crate::store::WorkflowStore;
7use crate::store::{NamespaceRecord, NamespaceStats, QueueStats};
8use crate::types::*;
9
10impl<S: WorkflowStore> WorkflowCtx<S> {
11    pub async fn create_namespace(&self, name: &str) -> Result<()> {
12        self.store.create_namespace(name).await
13    }
14
15    pub async fn list_namespaces(&self) -> Result<Vec<NamespaceRecord>> {
16        self.store.list_namespaces().await
17    }
18
19    pub async fn delete_namespace(&self, name: &str) -> Result<bool> {
20        self.store.delete_namespace(name).await
21    }
22
23    pub async fn get_namespace_stats(&self, namespace: &str) -> Result<NamespaceStats> {
24        self.store.get_namespace_stats(namespace).await
25    }
26
27    pub async fn get_queue_stats(&self, namespace: &str) -> Result<Vec<QueueStats>> {
28        self.store.get_queue_stats(namespace).await
29    }
30
31    pub async fn create_snapshot(
32        &self,
33        workflow_id: &str,
34        event_seq: i32,
35        state_json: &str,
36    ) -> Result<()> {
37        self.store
38            .create_snapshot(workflow_id, event_seq, state_json)
39            .await
40    }
41
42    pub async fn get_latest_snapshot(&self, workflow_id: &str) -> Result<Option<WorkflowSnapshot>> {
43        self.store.get_latest_snapshot(workflow_id).await
44    }
45}