Class: Hermes::EventProcessor
- Inherits:
-
Object
- Object
- Hermes::EventProcessor
- Extended by:
- Forwardable
- Defined in:
- lib/hermes/event_processor.rb
Defined Under Namespace
Classes: ProcessingResult
Class Method Summary collapse
Instance Method Summary collapse
- #call(event_class, body, headers) ⇒ Object
-
#initialize(distributed_trace_repository:, config:) ⇒ EventProcessor
constructor
A new instance of EventProcessor.
Constructor Details
#initialize(distributed_trace_repository:, config:) ⇒ EventProcessor
Returns a new instance of EventProcessor.
15 16 17 18 |
# File 'lib/hermes/event_processor.rb', line 15 def initialize(distributed_trace_repository:, config:) @distributed_trace_repository = distributed_trace_repository @config = config end |
Class Method Details
.call(event_class, body, headers) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/hermes/event_processor.rb', line 5 def self.call(event_class, body, headers) new( distributed_trace_repository: Hermes::DependenciesContainer["distributed_trace_repository"], config: Hermes::DependenciesContainer["config"] ).call(event_class, body, headers) end |
Instance Method Details
#call(event_class, body, headers) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hermes/event_processor.rb', line 20 def call(event_class, body, headers) event = Object.const_get(event_class).from_body_and_headers(body, headers) Hermes.with_origin_headers(headers) do instrumenter.instrument("Hermes.EventProcessor.#{event_class}") do response = infer_handler(event_class).call(event) distributed_trace_repository.create(event) ProcessingResult.new(event, response) end end end |