@@ -205,32 +205,30 @@ fn index_table(queue_name: &str) -> String {
205
205
format ! ( "{queue_name}___index" )
206
206
}
207
207
208
- /// time+id range record id, namely queue_table:[when,<uuid>task_id]
208
+ /// time+id range record id, namely ` queue_table` :[when,<uuid>` task_id` ]
209
209
fn queue_record_id ( queue_name : & str , when : & str , task_id : & str ) -> Result < RecordId , BroccoliError > {
210
210
// TODO: look at building the record programmatically, move when to typed
211
211
// compromise here is that we do explicit casting of the uuid, if it's not correct it will fail
212
212
let queue_table = self :: queue_table ( queue_name) ;
213
- let queue_record_str = format ! ( "{}:[{},<uuid>'{}']" , queue_table , when , task_id ) ;
213
+ let queue_record_str = format ! ( "{queue_table }:[{when },<uuid>'{task_id }']" ) ;
214
214
let queue_record_id = RecordId :: from_str ( & queue_record_str) ;
215
215
match queue_record_id {
216
216
Ok ( record_id) => Ok ( record_id) ,
217
217
Err ( e) => Err ( BroccoliError :: Broker ( format ! (
218
- "Incorrect task id for queue ({})" ,
219
- e
218
+ "Incorrect task id for queue ({e})"
220
219
) ) ) ,
221
220
}
222
221
}
223
222
224
- /// index_table:[<uuid>task_id, queue_name]
223
+ /// ` index_table` :[<uuid>` task_id`, ` queue_name` ]
225
224
fn index_record_id ( task_id : & str , queue_name : & str ) -> Result < RecordId , BroccoliError > {
226
225
let index_table = self :: index_table ( queue_name) ;
227
- let index_record_str = format ! ( "{}:[<uuid>'{}','{}']" , index_table , task_id , queue_name ) ;
226
+ let index_record_str = format ! ( "{index_table }:[<uuid>'{task_id }','{queue_name }']" ) ;
228
227
let index_record_id = RecordId :: from_str ( & index_record_str) ;
229
228
match index_record_id {
230
229
Ok ( record_id) => Ok ( record_id) ,
231
230
Err ( e) => Err ( BroccoliError :: Broker ( format ! (
232
- "Incorrect task id for index ({})" ,
233
- e
231
+ "Incorrect task id for index ({e})"
234
232
) ) ) ,
235
233
}
236
234
}
@@ -304,18 +302,17 @@ async fn add_record_to_queue(
304
302
} )
305
303
. await
306
304
. map_err ( |e : surrealdb:: Error | {
307
- BroccoliError :: Broker ( format ! ( "{}:'{}': {}" , err_msg , queue_name , e ) )
305
+ BroccoliError :: Broker ( format ! ( "{err_msg }:'{queue_name }': {e}" ) )
308
306
} ) ?;
309
307
match qm {
310
308
Some ( _) => {
311
309
// now we insert into the index and we are done, note we insert the queue id
312
- let _ = self :: add_to_queue_index ( & db , queue_name , task_id , queue_record_id , err_msg )
313
- . await ?;
310
+ let ( ) =
311
+ self :: add_to_queue_index ( db , queue_name , task_id , queue_record_id , err_msg ) . await ?;
314
312
Ok ( ( ) )
315
313
}
316
314
None => Err ( BroccoliError :: Broker ( format ! (
317
- "{}:'{}': adding to queue (silently did not add)" ,
318
- err_msg, queue_name,
315
+ "{err_msg}:'{queue_name}': adding to queue (silently did not add)" ,
319
316
) ) ) ,
320
317
}
321
318
}
@@ -326,7 +323,7 @@ async fn add_record_to_queue(
326
323
async fn add_to_queue_index (
327
324
db : & Surreal < Any > ,
328
325
queue_name : & str ,
329
- task_id : & String ,
326
+ task_id : & str ,
330
327
queue_id : RecordId , // queue:[timestamp, task_id]
331
328
err_msg : & ' static str ,
332
329
) -> Result < ( ) , BroccoliError > {
@@ -338,13 +335,12 @@ async fn add_to_queue_index(
338
335
. content ( InternalSurrealDBBrokerQueueIndex { queue_id } )
339
336
. await
340
337
. map_err ( |e : surrealdb:: Error | {
341
- BroccoliError :: Broker ( format ! ( "{}:'{}': {}" , err_msg , queue_name , e ) )
338
+ BroccoliError :: Broker ( format ! ( "{err_msg }:'{queue_name }': {e}" ) )
342
339
} ) ?;
343
340
match qm {
344
341
Some ( _) => Ok ( ( ) ) , // happy path
345
342
None => Err ( BroccoliError :: Broker ( format ! (
346
- "{}:'{}': adding to index (silently did not add)" ,
347
- err_msg, queue_name,
343
+ "{err_msg}:'{queue_name}': adding to index (silently did not add)" ,
348
344
) ) ) ,
349
345
}
350
346
}
@@ -362,7 +358,7 @@ async fn get_queue_index(
362
358
. select ( index_record_id)
363
359
. await
364
360
. map_err (
365
- |e : surrealdb:: Error | BroccoliError :: Broker ( format ! ( "{}:'{}': {}" , err_msg , queue_name , e ) ) ,
361
+ |e : surrealdb:: Error | BroccoliError :: Broker ( format ! ( "{err_msg }:'{queue_name }': {e}" ) ) ,
366
362
) ?;
367
363
Ok ( queue_index)
368
364
}
0 commit comments