module ActiveJob::Callbacks::ClassMethods
def after_enqueue(*filters, &blk)
end
end
Video.find(video_id).process
def perform(video_id)
end
$statsd.increment "enqueue-video-job.success"
after_enqueue do |job|
queue_as :default
class VideoProcessJob < ActiveJob::Base
job is enqueued.
Defines a callback that will get called right after the
def after_enqueue(*filters, &blk) set_callback(:enqueue, :after, *filters, &blk) end
def after_perform(*filters, &blk)
end
end
Video.find(video_id).process
def perform(video_id)
end
UserMailer.notify_video_processed(job.arguments.first)
after_perform do |job|
queue_as :default
class VideoProcessJob < ActiveJob::Base
job's perform method has finished.
Defines a callback that will get called right after the
def after_perform(*filters, &blk) set_callback(:perform, :after, *filters, &blk) end
def around_enqueue(*filters, &blk)
end
end
Video.find(video_id).process
def perform(video_id)
end
end
block.call
$statsd.time "video-job.process" do
around_enqueue do |job, block|
queue_as :default
class VideoProcessJob < ActiveJob::Base
of the job.
Defines a callback that will get called around the enqueuing
def around_enqueue(*filters, &blk) set_callback(:enqueue, :around, *filters, &blk) end
def around_perform(*filters, &blk)
end
end
"Hello World!"
def perform
end
puts value # => "Hello World!"
value = block.call
around_perform do |job, block|
class VideoProcessJob < ActiveJob::Base
You can access the return value of the job only if the execution wasn't halted.
end
end
Video.find(video_id).process
def perform(video_id)
end
UserMailer.notify_video_processed(job.arguments.first)
block.call
UserMailer.notify_video_started_processing(job.arguments.first)
around_perform do |job, block|
queue_as :default
class VideoProcessJob < ActiveJob::Base
Defines a callback that will get called around the job's perform method.
def around_perform(*filters, &blk) set_callback(:perform, :around, *filters, &blk) end
def before_enqueue(*filters, &blk)
end
end
Video.find(video_id).process
def perform(video_id)
end
$statsd.increment "enqueue-video-job.try"
before_enqueue do |job|
queue_as :default
class VideoProcessJob < ActiveJob::Base
job is enqueued.
Defines a callback that will get called right before the
def before_enqueue(*filters, &blk) set_callback(:enqueue, :before, *filters, &blk) end
def before_perform(*filters, &blk)
end
end
Video.find(video_id).process
def perform(video_id)
end
UserMailer.notify_video_started_processing(job.arguments.first)
before_perform do |job|
queue_as :default
class VideoProcessJob < ActiveJob::Base
job's perform method is executed.
Defines a callback that will get called right before the
def before_perform(*filters, &blk) set_callback(:perform, :before, *filters, &blk) end