boson_backend_sql_common/
delegate.rs1#[macro_export]
5macro_rules! delegate_queue_backend {
6 ($wrapper:ty, $inner:ident) => {
7 #[::async_trait::async_trait]
8 impl ::boson_core::QueueBackend for $wrapper {
9 async fn upsert_job(&self, job: &::boson_core::Job) -> ::boson_core::Result<()> {
10 self.$inner.upsert_job(job).await
11 }
12
13 async fn enqueue_with_policies(
14 &self,
15 job: ::boson_core::Job,
16 task_config: &::boson_core::TaskConfig,
17 ) -> ::boson_core::Result<(String, ::boson_core::JobEnqueueDisposition)> {
18 self.$inner.enqueue_with_policies(job, task_config).await
19 }
20
21 async fn get_job(&self, job_id: &str) -> ::boson_core::Result<Option<::boson_core::Job>> {
22 self.$inner.get_job(job_id).await
23 }
24
25 async fn list_jobs(
26 &self,
27 status_filter: Option<::boson_core::JobStatus>,
28 offset: usize,
29 limit: usize,
30 ) -> ::boson_core::Result<Vec<::boson_core::Job>> {
31 self.$inner.list_jobs(status_filter, offset, limit).await
32 }
33
34 async fn cancel_job_if_active(&self, job_id: &str) -> ::boson_core::Result<()> {
35 self.$inner.cancel_job_if_active(job_id).await
36 }
37
38 async fn try_claim_job(
39 &self,
40 job_id: &str,
41 ) -> ::boson_core::Result<Option<::boson_core::Job>> {
42 self.$inner.try_claim_job(job_id).await
43 }
44
45 async fn revert_job_to_queued(&self, job_id: &str) -> ::boson_core::Result<()> {
46 self.$inner.revert_job_to_queued(job_id).await
47 }
48
49 async fn distinct_pools_queued(&self) -> ::boson_core::Result<Vec<String>> {
50 self.$inner.distinct_pools_queued().await
51 }
52
53 async fn list_queued_for_pool_sorted(
54 &self,
55 pool: &str,
56 limit: usize,
57 ) -> ::boson_core::Result<Vec<::boson_core::Job>> {
58 self.$inner.list_queued_for_pool_sorted(pool, limit).await
59 }
60
61 async fn count_jobs(
62 &self,
63 status_filter: Option<::boson_core::JobStatus>,
64 ) -> ::boson_core::Result<u64> {
65 self.$inner.count_jobs(status_filter).await
66 }
67
68 async fn count_jobs_for_task(
69 &self,
70 task_name: &str,
71 status: Option<::boson_core::JobStatus>,
72 ) -> ::boson_core::Result<u64> {
73 self.$inner.count_jobs_for_task(task_name, status).await
74 }
75
76 async fn count_active_jobs_for_task(
77 &self,
78 task_name: &str,
79 ) -> ::boson_core::Result<u32> {
80 self.$inner.count_active_jobs_for_task(task_name).await
81 }
82
83 async fn find_nonterminal_by_idempotency_key(
84 &self,
85 key: &str,
86 ) -> ::boson_core::Result<Option<String>> {
87 self.$inner.find_nonterminal_by_idempotency_key(key).await
88 }
89
90 async fn upsert_run(&self, run: &::boson_core::Run) -> ::boson_core::Result<()> {
91 self.$inner.upsert_run(run).await
92 }
93
94 async fn get_run(&self, run_id: &str) -> ::boson_core::Result<Option<::boson_core::Run>> {
95 self.$inner.get_run(run_id).await
96 }
97
98 async fn list_runs(
99 &self,
100 job_id_filter: Option<&str>,
101 offset: usize,
102 limit: usize,
103 ) -> ::boson_core::Result<Vec<::boson_core::Run>> {
104 self.$inner.list_runs(job_id_filter, offset, limit).await
105 }
106
107 async fn finish_run(
108 &self,
109 run_id: &str,
110 status: ::boson_core::RunStatus,
111 duration_ms: Option<i64>,
112 error_message: Option<String>,
113 ) -> ::boson_core::Result<()> {
114 self.$inner
115 .finish_run(run_id, status, duration_ms, error_message)
116 .await
117 }
118
119 async fn count_runs(&self, job_id_filter: Option<&str>) -> ::boson_core::Result<u64> {
120 self.$inner.count_runs(job_id_filter).await
121 }
122
123 async fn count_runs_since(
124 &self,
125 since: ::chrono::DateTime<::chrono::Utc>,
126 ) -> ::boson_core::Result<u64> {
127 self.$inner.count_runs_since(since).await
128 }
129
130 async fn task_run_stats(
131 &self,
132 task_name: &str,
133 ) -> ::boson_core::Result<::boson_core::TaskRunStats> {
134 self.$inner.task_run_stats(task_name).await
135 }
136
137 async fn get_task_config(
138 &self,
139 task_name: &str,
140 ) -> ::boson_core::Result<Option<::boson_core::TaskConfig>> {
141 self.$inner.get_task_config(task_name).await
142 }
143
144 async fn upsert_task_config(
145 &self,
146 config: &::boson_core::TaskConfig,
147 ) -> ::boson_core::Result<()> {
148 self.$inner.upsert_task_config(config).await
149 }
150
151 async fn try_claim_run_lease(
152 &self,
153 job_id: &str,
154 worker_id: &str,
155 ttl_secs: i64,
156 ) -> ::boson_core::Result<Option<String>> {
157 self.$inner
158 .try_claim_run_lease(job_id, worker_id, ttl_secs)
159 .await
160 }
161
162 async fn extend_lease(&self, lease_id: &str, ttl_secs: i64) -> ::boson_core::Result<()> {
163 self.$inner.extend_lease(lease_id, ttl_secs).await
164 }
165
166 async fn release_lease(&self, lease_id: &str) -> ::boson_core::Result<()> {
167 self.$inner.release_lease(lease_id).await
168 }
169
170 async fn expired_lease_job_pairs(
171 &self,
172 ) -> ::boson_core::Result<Vec<(String, String)>> {
173 self.$inner.expired_lease_job_pairs().await
174 }
175 }
176 };
177}