lib/sidekiq/event_bus/consumer.rb
def consume topic, event, payload
    if self.class.handlers.key? event
      _payload = payload.merge('topic'.freeze => topic, 'event'.freeze => event).freeze

      if PAYLOAD_WITH_INDIFFERENT_ACCESS
        _payload = ActiveSupport::HashWithIndifferentAccess.new(_payload)
      end

      self.class.handlers[event].each do |handler|
        begin
          if handler.is_a? Proc
            instance_exec( _payload.dup, &handler )
          else
            handler.call( _payload.dup )
          end
        rescue => e
          Sidekiq::EventBus.utils.handle_error(e)
        end
      end
    end
  end
# Register Consumer with the EventBus for a particular topic
Register Consumer with the EventBus for a particular topic
Register Consumer with the EventBus for a particular topic
def consume topic, event, payload
    if self.class.handlers.key? event
      _payload = payload.merge('topic'.freeze => topic, 'event'.freeze => event).freeze
      if PAYLOAD_WITH_INDIFFERENT_ACCESS
        _payload = ActiveSupport::HashWithIndifferentAccess.new(_payload)
      end
      self.class.handlers[event].each do |handler|
        begin
          if handler.is_a? Proc
            instance_exec( _payload.dup, &handler )
          else
            handler.call( _payload.dup )
          end
        rescue => e
          Sidekiq::EventBus.utils.handle_error(e)
        end
      end
    end
  end
def consume topic , event , payload if self . class . handlers . key? event _payload = payload . merge ( 'topic' . freeze => topic , 'event' . freeze => event ) . freeze if PAYLOAD_WITH_INDIFFERENT_ACCESS _payload = ActiveSupport :: HashWithIndifferentAccess . new ( _payload ) end self . class . handlers [ event ] . each do | handler | begin if handler . is_a? Proc instance_exec ( _payload . dup , & handler ) else handler . call ( _payload . dup ) end rescue => e Sidekiq :: EventBus . utils . handle_error ( e ) end end end end
Register Consumer with the EventBus for a particular topic
Register Consumer with the EventBus for a particular topic
topic
event
payload