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
- .do_fetch(type) ⇒ Object
- .fetch(type) {|task| ... } ⇒ Object
- .monitoring ⇒ Object
Class Method Details
.autoreprocess(reprocess_limit = nil) ⇒ Object
58 59 60 61 62 |
# File 'lib/tasque/task.rb', line 58 def autoreprocess(reprocess_limit = nil) Tasque::Task.to_reprocess.limit(reprocess_limit.to_i).each do |task| task.reprocess end.count end |
.do_fetch(type) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/tasque/task.rb', line 27 def do_fetch(type) 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 task end end |
.fetch(type) {|task| ... } ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tasque/task.rb', line 36 def fetch(type, &block) task = nil if Tasque.config.use_mutex && defined?(RedisMutex) RedisMutex.with_lock(Tasque.config.mutex_name, Tasque.config.) do task = do_fetch(type) end else transaction do task = do_fetch(type) end end yield(task) if task !!task end |