2019-08-14 09:48:44 +00:00
|
|
|
class Dispatcher
|
|
|
|
include Singleton
|
|
|
|
|
|
|
|
attr_reader :async_dispatcher, :sync_dispatcher
|
|
|
|
|
|
|
|
def self.dispatch(event_name, timestamp, data, async = false)
|
2019-10-12 18:08:41 +00:00
|
|
|
Rails.configuration.dispatcher.dispatch(event_name, timestamp, data, async)
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
@sync_dispatcher = SyncDispatcher.new
|
|
|
|
@async_dispatcher = AsyncDispatcher.new
|
|
|
|
end
|
|
|
|
|
2019-10-20 08:47:26 +00:00
|
|
|
def dispatch(event_name, timestamp, data, _async = false)
|
2019-08-14 09:48:44 +00:00
|
|
|
@sync_dispatcher.dispatch(event_name, timestamp, data)
|
|
|
|
@async_dispatcher.dispatch(event_name, timestamp, data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_listeners
|
|
|
|
@sync_dispatcher.load_listeners
|
|
|
|
@async_dispatcher.load_listeners
|
|
|
|
end
|
|
|
|
end
|