Class: Lapine::Consumer::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/lapine/consumer/dispatcher.rb

Defined Under Namespace

Classes: DefaultErrorHandler

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegate_class, message) ⇒ Dispatcher

Returns a new instance of Dispatcher.



23
24
25
26
27
# File 'lib/lapine/consumer/dispatcher.rb', line 23

def initialize(delegate_class, message)
  @delegate_class = delegate_class
  @message = message
  @payload = message.decoded_payload
end

Instance Attribute Details

#delegate_classObject (readonly)

Returns the value of attribute delegate_class.



13
14
15
# File 'lib/lapine/consumer/dispatcher.rb', line 13

def delegate_class
  @delegate_class
end

#messageObject (readonly)

Returns the value of attribute message.



13
14
15
# File 'lib/lapine/consumer/dispatcher.rb', line 13

def message
  @message
end

#payloadObject (readonly)

Returns the value of attribute payload.



13
14
15
# File 'lib/lapine/consumer/dispatcher.rb', line 13

def payload
  @payload
end

Class Method Details

.error_handlerObject



19
20
21
# File 'lib/lapine/consumer/dispatcher.rb', line 19

def self.error_handler
  @error_handler || DefaultErrorHandler.new
end

.error_handler=(handler) ⇒ Object



15
16
17
# File 'lib/lapine/consumer/dispatcher.rb', line 15

def self.error_handler=(handler)
  @error_handler = handler
end

Instance Method Details

#dispatchObject



29
30
31
32
33
# File 'lib/lapine/consumer/dispatcher.rb', line 29

def dispatch
  Lapine::DTrace.fire!(:dispatch_enter, delegate_class.name, message.payload)
  with_timed_logging(payload) { do_dispatch(payload) }
  Lapine::DTrace.fire!(:dispatch_return, delegate_class.name, message.payload)
end