Sha256: 3994d67f88925e7e65886ca04d169669ec0228707c24a3c9a5e53f1e4a7722f3
Contents?: true
Size: 893 Bytes
Versions: 39
Compression:
Stored size: 893 Bytes
Contents
# encoding: utf-8 module OneApm::Support class EventListener attr_accessor :runaway_threshold def initialize @events = {} @runaway_threshold = 100 end def subscribe(event, &handler) @events[event] ||= [] @events[event] << handler check_for_runaway_subscriptions(event) end def check_for_runaway_subscriptions(event) count = @events[event].size OneApm::Manager.logger.debug("Run-away event subscription on #{event}? Subscribed #{count}") if count > @runaway_threshold end def clear @events.clear end def notify(event, *args) return unless @events.has_key?(event) @events[event].each do |handler| begin handler.call(*args) rescue => err OneApm::Manager.logger.debug("Failure during notify for #{event}", err) end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems