Sha256: cacbf1fb111deb243793f69a9ba9f282fdaa5b397511a433bb83ff7dd2bda5f8
Contents?: true
Size: 1005 Bytes
Versions: 22
Compression:
Stored size: 1005 Bytes
Contents
module Kuroko2 module Workflow module Notifier NOTIFY_IN_THREAD = !Rails.env.test? 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 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 private_class_method :notify_with_notifier end end end
Version data entries
22 entries across 22 versions & 1 rubygems