Class: Hermes::EventProducer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hermes/event_producer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(publisher:, serializer:, distributed_trace_repository:, producer_error_handler:, config:) ⇒ EventProducer

Returns a new instance of EventProducer.



22
23
24
25
26
27
28
# File 'lib/hermes/event_producer.rb', line 22

def initialize(publisher:, serializer:, distributed_trace_repository:, producer_error_handler:, config:)
  @publisher = publisher
  @serializer = serializer
  @distributed_trace_repository = distributed_trace_repository
  @producer_error_handler = producer_error_handler
  @config = config
end

Class Method Details

.buildObject



12
13
14
15
16
17
18
19
20
# File 'lib/hermes/event_producer.rb', line 12

def self.build
  new(
    publisher: Hermes::DependenciesContainer["publisher"],
    serializer: Hermes::DependenciesContainer["serializer"],
    distributed_trace_repository: Hermes::DependenciesContainer["distributed_trace_repository"],
    producer_error_handler: Hermes::DependenciesContainer["producer_error_handler"],
    config: Hermes::DependenciesContainer["config"]
  )
end

.publish(event, properties = {}, options = {}) ⇒ Object



8
9
10
# File 'lib/hermes/event_producer.rb', line 8

def self.publish(event, properties = {}, options = {})
  build.publish(event, properties, options)
end

Instance Method Details

#publish(event, properties = {}, options = {}) ⇒ Object



30
31
32
33
34
# File 'lib/hermes/event_producer.rb', line 30

def publish(event, properties = {}, options = {})
  producer_error_handler.call(event) do
    publish_event(event, properties, options).tap { store_trace(event) }
  end
end