Skip to content

Commit c844e06

Browse files
aleclarsonTotktonada
authored andcommitted
refactoring: remove unneeded transform in "tube.delete"
All the queue drivers do "transform(2, 1, state.DONE)" before returning the task from their "delete" method. Also, changing the status of a task from abstract.lua is a violation of encapsulation. Patch changes: * remove the unnecessary "transform" operation from "tube.delete" * update description of a driver delete method in documentation Co-authored-by: Leonid Vasiliev<lvasiliev@tarantool.org>
1 parent e2b80a5 commit c844e06

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,8 @@ which is passed on to the user (removes the administrative fields)
631631
Returns a normalized task which represents a tuple in the space
632632
* `tube:take()` - sets the task state to 'in progress' and returns the task.
633633
If there are no 'ready' tasks in the queue, returns nil.
634-
* `tube:delete(task_id)` - deletes a task from the queue
634+
* `tube:delete(task_id)` - deletes a task from the queue.
635+
Returns the original task with a state changed to 'done'
635636
* `tube:release(task_id, opts)` - puts a task back to the queue (in the 'ready'
636637
state)
637638
* `tube:bury(task_id)` - buries a task

queue/abstract.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ end
223223

224224
function tube.delete(self, id)
225225
self:peek(id)
226-
return self.raw:normalize_task(
227-
self.raw:delete(id):transform(2, 1, state.DONE))
226+
return self.raw:normalize_task(self.raw:delete(id))
228227
end
229228

230229
-- drop tube

0 commit comments

Comments
 (0)