@@ -233,7 +233,7 @@ function method.put(args)
233
233
local ttr = args .ttr or args .options .ttr or ttl
234
234
local priority = args .priority or args .options .priority or 0
235
235
236
- local task = box .atomic (function ()
236
+ local task = utils .atomic (function ()
237
237
local idx = get_index (args .tube_name , args .bucket_id )
238
238
239
239
local next_event
301
301
302
302
function method .take (args )
303
303
304
- local task = box .atomic (take , args )
304
+ local task = utils .atomic (take , args )
305
305
if task == nil then return end
306
306
307
307
if args .extra and args .extra .log_request then
@@ -314,10 +314,14 @@ function method.take(args)
314
314
end
315
315
316
316
function method .delete (args )
317
- box .begin ()
318
- local task = box .space [args .tube_name ]:get (args .task_id )
319
- box .space [args .tube_name ]:delete (args .task_id )
320
- box .commit ()
317
+ local task = utils .atomic (function ()
318
+ local task = box .space [args .tube_name ]:get (args .task_id )
319
+ if task ~= nil then
320
+ box .space [args .tube_name ]:delete (args .task_id )
321
+ end
322
+ return task
323
+ end )
324
+
321
325
if task ~= nil then
322
326
task = task :tomap ()
323
327
task .status = state .DONE
@@ -355,10 +359,13 @@ function method.touch(args)
355
359
end
356
360
357
361
function method .ack (args )
358
- box .begin ()
359
- local task = box .space [args .tube_name ]:get (args .task_id )
360
- box .space [args .tube_name ]:delete (args .task_id )
361
- box .commit ()
362
+ local task = utils .atomic (function ()
363
+ local task = box .space [args .tube_name ]:get (args .task_id )
364
+ if task ~= nil then
365
+ box .space [args .tube_name ]:delete (args .task_id )
366
+ end
367
+ return task
368
+ end )
362
369
if task ~= nil then
363
370
task = task :tomap ()
364
371
task .status = state .DONE
@@ -385,15 +392,16 @@ function method.peek(args)
385
392
end
386
393
387
394
function method .release (args )
388
- box .begin ()
389
- local task = box .space [args .tube_name ]:get (args .task_id )
390
- if task ~= nil then
391
- task = box .space [args .tube_name ]:update (args .task_id , {
392
- {' =' , index .status , state .READY },
393
- {' =' , index .next_event , task [index .created ] + task [index .ttl ]},
394
- })
395
- end
396
- box .commit ()
395
+ local task = utils .atomic (function ()
396
+ local task = box .space [args .tube_name ]:get (args .task_id )
397
+ if task ~= nil then
398
+ task = box .space [args .tube_name ]:update (args .task_id , {
399
+ {' =' , index .status , state .READY },
400
+ {' =' , index .next_event , task [index .created ] + task [index .ttl ]},
401
+ })
402
+ end
403
+ return task
404
+ end )
397
405
398
406
if args .extra and args .extra .log_request then
399
407
log_operation (" release" , task )
@@ -408,15 +416,16 @@ function method.bury(args)
408
416
update_stat (args .tube_name , ' bury' )
409
417
wc_signal (args .tube_name )
410
418
411
- box .begin ()
412
- local task = box .space [args .tube_name ]:get (args .task_id )
413
- if task ~= nil then
414
- task = box .space [args .tube_name ]:update (args .task_id , {
415
- {' =' , index .status , state .BURIED },
416
- {' =' , index .next_event , task [index .created ] + task [index .ttl ]},
417
- })
418
- end
419
- box .commit ()
419
+ local task = utils .atomic (function ()
420
+ local task = box .space [args .tube_name ]:get (args .task_id )
421
+ if task ~= nil then
422
+ task = box .space [args .tube_name ]:update (args .task_id , {
423
+ {' =' , index .status , state .BURIED },
424
+ {' =' , index .next_event , task [index .created ] + task [index .ttl ]},
425
+ })
426
+ end
427
+ return task
428
+ end )
420
429
421
430
if args .extra and args .extra .log_request then
422
431
log_operation (" bury" , task )
0 commit comments