module Roundhouse::Util
This module is part of Roundhouse
core and not intended for extensions.
Constants
- EXPIRY
Public Instance Methods
fire_event(event, reverse=false)
click to toggle source
# File lib/roundhouse/util.rb, line 42 def fire_event(event, reverse=false) arr = Roundhouse.options[:lifecycle_events][event] arr.reverse! if reverse arr.each do |block| begin block.call rescue => ex handle_exception(ex, { event: event }) end end end
hostname()
click to toggle source
# File lib/roundhouse/util.rb, line 30 def hostname ENV['DYNO'] || Socket.gethostname end
identity()
click to toggle source
# File lib/roundhouse/util.rb, line 38 def identity @@identity ||= "#{hostname}:#{$$}:#{process_nonce}" end
logger()
click to toggle source
# File lib/roundhouse/util.rb, line 22 def logger Roundhouse.logger end
process_nonce()
click to toggle source
# File lib/roundhouse/util.rb, line 34 def process_nonce @@process_nonce ||= SecureRandom.hex(6) end
redis(&block)
click to toggle source
# File lib/roundhouse/util.rb, line 26 def redis(&block) Roundhouse.redis(&block) end
want_a_hertz_donut?()
click to toggle source
# File lib/roundhouse/util.rb, line 54 def want_a_hertz_donut? # what's a hertz donut? # punch! Hurts, don't it? info = Roundhouse.redis {|c| c.info } if info['connected_clients'].to_i > 1000 && info['hz'].to_i >= 10 Roundhouse.logger.warn { "Your Redis `hz` setting is too high at #{info['hz']}. See mperham/sidekiq#2431. Set it to 3 in #{info[:config_file]}" } true else Roundhouse.logger.debug { "Redis hz: #{info['hz']}. Client count: #{info['connected_clients']}" } false end end
watchdog(last_words) { || ... }
click to toggle source
# File lib/roundhouse/util.rb, line 15 def watchdog(last_words) yield rescue Exception => ex handle_exception(ex, { context: last_words }) raise ex end