-
-
Save entity1991/22d2f8aea5fbbba6c376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage | |
# DJ config | |
require Rails.root.join('lib', 'dj_plugin.rb') | |
Delayed::Worker.plugins << Delayed::Plugins::EmailNotify | |
# lib/dj_plugin.rb | |
require 'exception_notification' | |
module Delayed::Plugins | |
class EmailNotify < ::Delayed::Plugin | |
module Notify | |
def error(job, exception) | |
ExceptionNotifier.notify_exception(exception, email_prefix: '[ERROR] [DJ] ') | |
super if defined?(super) | |
end | |
end | |
callbacks do |lifecycle| | |
lifecycle.before(:invoke_job) do |job| | |
payload = job.payload_object | |
payload = payload.object if payload.is_a? Delayed::PerformableMethod | |
payload.extend Notify | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment