Sha256: a24e00d682d108f7f0dfb6ac1f7eb049cff4c5d2e78c26ca7aaf0eb9ff88afd4

Contents?: true

Size: 943 Bytes

Versions: 42

Compression:

Stored size: 943 Bytes

Contents

module ActionSubscriber
  module Middleware
    class Router
      INSTRUMENT_KEY = "process_event.action_subscriber".freeze
      include ::ActionSubscriber::Logging

      def initialize(app)
        @app = app
      end

      def call(env)
        action = env.action
        message_id = env.message_id
        queue = env.queue
        routing_key = env.routing_key
        subscriber = env.subscriber

        logger.info { "START #{message_id} #{subscriber}##{action}" }

        instrument_call(subscriber, routing_key, queue) do
          subscriber.run_action_with_filters(env, action)
        end

        logger.info { "FINISHED #{message_id}" }
      end

    private

      def instrument_call(subscriber, routing_key, queue)
        ::ActiveSupport::Notifications.instrument INSTRUMENT_KEY, :subscriber => subscriber.to_s, :routing_key => routing_key, :queue => queue do
          yield
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
action_subscriber-5.3.3-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.3 lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.2-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.2 lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.1-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.1 lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.1.pre-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.1.pre lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.0-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.3.0 lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.4-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.4 lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.3-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.3 lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.2-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.2 lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.1-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.1 lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.0-java lib/action_subscriber/middleware/router.rb
action_subscriber-5.2.0 lib/action_subscriber/middleware/router.rb