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

Version Path
kuroko2-0.8.0 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.7.0 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.6.0 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.5.2 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.5.1 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.5.0 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.6 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.5 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.4 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.3 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.2 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.1 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.4.0 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.3.4 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.3.3 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.3.2 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.3.1 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.3.0 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.2.3 lib/autoload/kuroko2/workflow/notifier.rb
kuroko2-0.2.2 lib/autoload/kuroko2/workflow/notifier.rb