module Kuroko2::Workflow::Notifier

Constants

NOTIFY_IN_THREAD

Public Class Methods

notify(method, job_instance) click to toggle source
# File lib/autoload/kuroko2/workflow/notifier.rb, line 6
def self.notify(method, job_instance)
  Kuroko2.config.notifiers.keys.each do |notifier_name|
    notifier = const_get(notifier_name.camelize, false)
    if NOTIFY_IN_THREAD
      Thread.new { notify_with_notifier(job_instance, method, notifier) }
    else
      # for test
      notify_with_notifier(job_instance, method, notifier)
    end
  end
end

Private Class Methods

notify_with_notifier(job_instance, method, notifier) click to toggle source
# File lib/autoload/kuroko2/workflow/notifier.rb, line 18
def self.notify_with_notifier(job_instance, method, notifier)
  begin
    ActiveRecord::Base.connection_pool.with_connection do
      notifier.new(job_instance).send(:"notify_#{method}")
    end
  rescue Exception => e
    Kuroko2.logger.warn("Failure to notify #{method} with #{notifier} for '#{job_instance.job_definition.name}'. #{e.class}: #{e.message}")
  end
end