class EventStoreClient::Broker
Attributes
connection[R]
logger[R]
threads[RW]
Public Class Methods
new(connection:)
click to toggle source
# File lib/event_store_client/broker.rb, line 34 def initialize(connection:) @connection = connection @threads = [] @logger = EventStoreClient.config.logger end
Public Instance Methods
call(subscriptions, wait: false)
click to toggle source
Distributes known subscriptions to multiple threads @param [EventStoreClient::Subscriptions] @param wait [Boolean] (Optional) Controls if broker should block
main app process (useful for debugging)
# 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