Sha256: cf13d9603f4e58400c9a33c1daa7792630563899108a4dcfd76353fceba500e5
Contents?: true
Size: 769 Bytes
Versions: 4
Compression:
Stored size: 769 Bytes
Contents
module Alondra class EventRouter def self.listeners @listeners ||= [] end def process(event) event.channel.receive(event) # Event listeners callback can manipulate AR objects and so can potentially # block the EM reactor thread. To avoid that, we defer them to another thread. EM.defer do # Ensure the connection associated with the thread is checked in # after the callbacks are processed ActiveRecord::Base.connection_pool.with_connection do listening_classes = EventRouter.listeners.select do |ob| ob.listen_to?(event.channel_name) end listening_classes.each { |listening_class| listening_class.process(event) } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
alondra-0.1.1 | lib/alondra/event_router.rb |
alondra-0.1.0 | lib/alondra/event_router.rb |
alondra-0.0.4 | lib/alondra/event_router.rb |
alondra-0.0.3 | lib/alondra/event_router.rb |