Module: RocketJob::Plugins::Job::Worker::ClassMethods
- Defined in:
- lib/rocket_job/plugins/job/worker.rb
Instance Method Summary collapse
-
#perform_now(args) {|job| ... } ⇒ Object
Run this job now.
-
#requeue_dead_server(server_name) ⇒ Object
Requeues all jobs that were running on a server that died.
Instance Method Details
#perform_now(args) {|job| ... } ⇒ Object
Run this job now.
The job is not saved to the database since it is processed entirely in memory As a result before_save and before_destroy callbacks will not be called. Validations are still called however prior to calling #perform
Note:
-
Only batch throttles are checked when perform_now is called.
19 20 21 22 23 24 |
# File 'lib/rocket_job/plugins/job/worker.rb', line 19 def perform_now(args) job = new(args) yield(job) if block_given? job.perform_now job end |
#requeue_dead_server(server_name) ⇒ Object
Requeues all jobs that were running on a server that died
27 28 29 30 31 32 33 34 |
# File 'lib/rocket_job/plugins/job/worker.rb', line 27 def requeue_dead_server(server_name) # Need to requeue paused, failed since user may have transitioned job before it finished with(read: {mode: :primary}) do |conn| conn.where(:state.in => %i[running paused failed]).each do |job| job.requeue!(server_name) if job.may_requeue?(server_name) end end end |