Sha256: 43526fa9ab58daaea7c83597dd8afbd74dba96b2eebb043d5f001190bfb20237
Contents?: true
Size: 1.7 KB
Versions: 5
Compression:
Stored size: 1.7 KB
Contents
# encoding: utf-8 ## # HireFire # This is a HireFire modified version of # the official Resque::Job class module ::Resque class Job def perform job = payload_class job_args = args || [] job_was_performed = false before_hooks = Plugin.before_hooks(job) around_hooks = Plugin.around_hooks(job) after_hooks = Plugin.after_hooks(job) failure_hooks = Plugin.failure_hooks(job) begin begin before_hooks.each do |hook| job.send(hook, *job_args) end rescue DontPerform return false end if around_hooks.empty? job.perform(*job_args) job_was_performed = true else stack = around_hooks.reverse.inject(nil) do |last_hook, hook| if last_hook lambda do job.send(hook, *job_args) { last_hook.call } end else lambda do job.send(hook, *job_args) do result = job.perform(*job_args) job_was_performed = true result end end end end stack.call end ## # HireFire Hook # After a job finishes processing, we invoke the #fire # method on the environment object which will check to see whether # we can fire all the hired workers ::Resque::Job.environment.fire after_hooks.each do |hook| job.send(hook, *job_args) end return job_was_performed rescue Object => e failure_hooks.each { |hook| job.send(hook, e, *job_args) } raise e end end end end
Version data entries
5 entries across 5 versions & 2 rubygems