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