@@ -4,10 +4,10 @@ use diesel::dsl::{exists, not};
4
4
use diesel:: sql_types:: { Int2 , Jsonb , Text } ;
5
5
use diesel:: { ExpressionMethods , IntoSql , OptionalExtension , QueryDsl } ;
6
6
use diesel_async:: { AsyncPgConnection , RunQueryDsl } ;
7
- use futures_util:: future:: BoxFuture ;
8
7
use futures_util:: FutureExt ;
9
- use serde :: de :: DeserializeOwned ;
8
+ use futures_util :: future :: BoxFuture ;
10
9
use serde:: Serialize ;
10
+ use serde:: de:: DeserializeOwned ;
11
11
use serde_json:: Value ;
12
12
use std:: future:: Future ;
13
13
use tracing:: instrument;
@@ -61,12 +61,12 @@ pub trait BackgroundJob: Serialize + DeserializeOwned + Send + Sync + 'static {
61
61
}
62
62
}
63
63
64
- fn enqueue_deduplicated (
64
+ fn enqueue_deduplicated < ' a > (
65
65
conn : & mut AsyncPgConnection ,
66
- job_type : & ' static str ,
66
+ job_type : & ' a str ,
67
67
data : Value ,
68
68
priority : i16 ,
69
- ) -> impl Future < Output = Result < Option < i64 > , EnqueueError > > {
69
+ ) -> BoxFuture < ' a , Result < Option < i64 > , EnqueueError > > {
70
70
let similar_jobs = background_jobs:: table
71
71
. select ( background_jobs:: id)
72
72
. filter ( background_jobs:: job_type. eq ( job_type) )
@@ -92,15 +92,15 @@ fn enqueue_deduplicated(
92
92
. returning ( background_jobs:: id)
93
93
. get_result :: < i64 > ( conn) ;
94
94
95
- async move { Ok ( future. await . optional ( ) ?) }
95
+ async move { Ok ( future. await . optional ( ) ?) } . boxed ( )
96
96
}
97
97
98
- fn enqueue_simple (
98
+ fn enqueue_simple < ' a > (
99
99
conn : & mut AsyncPgConnection ,
100
- job_type : & ' static str ,
100
+ job_type : & ' a str ,
101
101
data : Value ,
102
102
priority : i16 ,
103
- ) -> impl Future < Output = Result < i64 , EnqueueError > > {
103
+ ) -> BoxFuture < ' a , Result < i64 , EnqueueError > > {
104
104
let future = diesel:: insert_into ( background_jobs:: table)
105
105
. values ( (
106
106
background_jobs:: job_type. eq ( job_type) ,
@@ -110,5 +110,5 @@ fn enqueue_simple(
110
110
. returning ( background_jobs:: id)
111
111
. get_result ( conn) ;
112
112
113
- async move { Ok ( future. await ?) }
113
+ async move { Ok ( future. await ?) } . boxed ( )
114
114
}
0 commit comments