Class: Hermes::RetryableEventProducer

Inherits:
Object
  • Object
show all
Defined in:
lib/hermes/retryable_event_producer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects_resolver:, event_producer:) ⇒ RetryableEventProducer

Returns a new instance of RetryableEventProducer.



13
14
15
16
# File 'lib/hermes/retryable_event_producer.rb', line 13

def initialize(objects_resolver:, event_producer:)
  @objects_resolver = objects_resolver
  @event_producer = event_producer
end

Class Method Details

.publish(event_class, event_body, origin_headers) ⇒ Object



3
4
5
6
7
8
# File 'lib/hermes/retryable_event_producer.rb', line 3

def self.publish(event_class, event_body, origin_headers)
  new(
    objects_resolver: Hermes::DependenciesContainer["objects_resolver"],
    event_producer: Hermes::DependenciesContainer["event_producer"]
  ).publish(event_class, event_body, origin_headers)
end

Instance Method Details

#publish(event_class, event_body, origin_headers) ⇒ Object



18
19
20
21
22
# File 'lib/hermes/retryable_event_producer.rb', line 18

def publish(event_class, event_body, origin_headers)
  event = objects_resolver.const_get(event_class).new(event_body.deep_symbolize_keys)
  event.origin_headers = origin_headers.except(Hermes::B3PropagationModelHeaders.span_id_key)
  event_producer.publish(event)
end