Module: Delayed::Backend::Base::ClassMethods
- Defined in:
- lib/delayed/backend/base.rb
Instance Method Summary collapse
-
#after_fork ⇒ Object
Hook method that is called after a new worker is forked.
-
#before_fork ⇒ Object
Hook method that is called before a new worker is forked.
-
#enqueue(*args) ⇒ Object
Add a job to the queue.
- #work_off(num = 100) ⇒ Object
Instance Method Details
#after_fork ⇒ Object
Hook method that is called after a new worker is forked
32 33 |
# File 'lib/delayed/backend/base.rb', line 32 def after_fork end |
#before_fork ⇒ Object
Hook method that is called before a new worker is forked
28 29 |
# File 'lib/delayed/backend/base.rb', line 28 def before_fork end |
#enqueue(*args) ⇒ Object
Add a job to the queue
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/delayed/backend/base.rb', line 13 def enqueue(*args) object = args.shift unless object.respond_to?(:perform) raise ArgumentError, 'Cannot enqueue items which do not respond to perform' end priority = args.first || Delayed::Worker.default_priority run_at = args[1] # we just added queue to the positional argument list and to self.create, # TODO will it break for other backends where :queue is not defined yet? queue = args[2] || Delayed::Worker.queue self.create(:payload_object => object, :priority => priority.to_i, :run_at => run_at, :queue => queue) end |