Class: Hermes::EventProducer
- Inherits:
-
Object
- Object
- Hermes::EventProducer
- Extended by:
- Forwardable
- Defined in:
- lib/hermes/event_producer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(publisher:, serializer:, distributed_trace_repository:, producer_error_handler:, config:) ⇒ EventProducer
constructor
A new instance of EventProducer.
- #publish(event, properties = {}, options = {}) ⇒ Object
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
.build ⇒ Object
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 = {}, = {}) build.publish(event, properties, ) 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 = {}, = {}) producer_error_handler.call(event) do publish_event(event, properties, ).tap { store_trace(event) } end end |