diff --git a/src/worker/task.cr b/src/worker/task.cr index 07ec87c..68d327b 100644 --- a/src/worker/task.cr +++ b/src/worker/task.cr @@ -1,6 +1,19 @@ require "./task/**" abstract class Mel::Task + def dequeue_pending + do_before_dequeue + log_dequeueing + + Query.delete_pending(id).tap do + log_dequeued + do_after_dequeue(true) + end + rescue error + handle_error(error) + do_after_enqueue(false) + end + def run(*, force = false) : Fiber? return log_not_due unless force || due? @@ -50,19 +63,6 @@ abstract class Mel::Task do_after_run(false) end - def dequeue_pending - do_before_dequeue - log_dequeueing - - Query.delete_pending(id).tap do - log_dequeued - do_after_dequeue(true) - end - rescue error - handle_error(error) - do_after_enqueue(false) - end - macro inherited def self.find_pending(count : Int, *, delete = false) : Array(self)? return if count.zero?