lib/maglev/listeners/broadcaster.rb
# broadcastes an event to listeners and spies.
broadcastes an event to listeners and spies.
broadcastes an event to listeners and spies .
def broadcast(event, spies_only: false, force_targets: MagLev.config.listeners.broadcast_mode == :specified, source: nil)
      unless enabled?
        MagLev.logger.info "Broadcaster is disabled, skipping #{event} broadcast"
        return
      end
      raise EventError.new("Event #{event.event_name} already broadcasted") if event.broadcasted?
      if event.targets.none? and force_targets
        raise ConfigurationError.new("broadcast_mode is set to specified but no event targets were given for #{event.name}")
      end
      context = { event: event.name, source: source }
      MagLev::Statsd.perform('broadcasts', context) do
        with_event(event) do
          MagLev::EventReporter.with_context(:broadcast, context) do
            broadcast_listeners(source) unless spies_only
            broadcast_spies
          end
        end
      end
      broadcasted.shift if broadcasted.size >= 1000
      broadcasted << event
      event 
    end
def broadcast ( event , spies_only : false , force_targets : MagLev . config . listeners . broadcast_mode == :specified , source : nil ) unless enabled? MagLev . logger . info "Broadcaster is disabled, skipping #{event} broadcast" return end raise EventError . new ( "Event #{event.event_name} already broadcasted" ) if event . broadcasted? if event . targets . none? and force_targets raise ConfigurationError . new ( "broadcast_mode is set to specified but no event targets were given for #{event.name}" ) end context = { event : event . name , source : source } MagLev :: Statsd . perform ( 'broadcasts' , context ) do with_event ( event ) do MagLev :: EventReporter . with_context ( :broadcast , context ) do broadcast_listeners ( source ) unless spies_only broadcast_spies end end end broadcasted . shift if broadcasted . size >= 1000 broadcasted << event event end
broadcastes an event to listeners and spies.
broadcastes an event to listeners and spies .
# only track up to the most recent 1000 events # return the event so that chaining can be used and to indicate success
event
<not_specific>
spies_only
<not_specific>
force_targets
<not_specific>
config
<not_specific>
listeners
<not_specific>
broadcast_mode
<not_specific>
source
<not_specific>