Class: EventStoreClient::Broker
- Inherits:
-
Object
- Object
- EventStoreClient::Broker
- Includes:
- Configuration
- Defined in:
- lib/event_store_client/broker.rb
Instance Method Summary collapse
-
#call(subscriptions, wait: false) ⇒ Object
Distributes known subscriptions to multiple threads.
Methods included from Configuration
Instance Method Details
#call(subscriptions, wait: false) ⇒ Object
Distributes known subscriptions to multiple threads
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/event_store_client/broker.rb', line 12 def call(subscriptions, wait: false) Signal.trap('TERM') do Thread.new { logger&.info('Broker: TERM Signal has been received') } threads.each do |thread| thread.thread_variable_set(:terminate, true) end Thread.new { logger&.info('Broker: Terminate variable for subscription threads set') } end subscriptions.each do |subscription| threads << Thread.new do subscriptions.listen(subscription) end end threads.each(&:join) if wait end |