Class: Tasque::Task
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Tasque::Task
- Extended by:
- StateMachine::MacroMethods
- Defined in:
- lib/tasque/task.rb
Constant Summary collapse
- MAX_ATTEMPTS =
3
Class Method Summary collapse
- .autoreprocess(reprocess_limit = nil) ⇒ Object
- .fetch(type) {|task| ... } ⇒ Object
- .monitoring ⇒ Object
Class Method Details
.autoreprocess(reprocess_limit = nil) ⇒ Object
49 50 51 52 53 |
# File 'lib/tasque/task.rb', line 49 def autoreprocess(reprocess_limit = nil) Tasque::Task.to_reprocess.limit(reprocess_limit.to_i).each do |task| task.reprocess end.count end |
.fetch(type) {|task| ... } ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tasque/task.rb', line 27 def fetch(type, &block) task = nil transaction do minimum_priority = Tasque.config.minimum_priority task = self.with_task(type).to_process.minimum_priority(minimum_priority).lock(true).first if task and task.can_pickup? task.pickup else task = nil end end yield(task) if task !!task end |
.monitoring ⇒ Object
42 43 44 45 46 47 |
# File 'lib/tasque/task.rb', line 42 def monitoring { queue: Tasque::Task.to_process.count, errors: Tasque::Task.with_error.finished_in(1.hour).count } end |