module Flapjack

TODO options should be overridden by similar config file options

Alert is the object ready to send to someone, complete with an address and all the data with which to render the text of the alert in the appropriate gateway

klass and type are set for those relationships that call methods rather than regular Zermelo associations. Maybe this should be a separate descriptor type?

Hat-tip to github.com/glasnt for the suggestion

Constants

DEFAULT_INITIAL_FAILURE_DELAY
DEFAULT_INITIAL_RECOVERY_DELAY

defaulting to 0 for backwards compatibility; can be overridden in config, or per check / event

DEFAULT_REPEAT_FAILURE_DELAY
UUID_RE
VERSION

Public Class Methods

configure_log(name, config = {}) click to toggle source

Thread and fiber-local

# File lib/flapjack/logger.rb, line 12
def configure_log(name, config = {})
  Thread.current[:flapjack_logger_name]   = name
  Thread.current[:flapjack_logger_config] = config
end
dump_json(data) click to toggle source
# File lib/flapjack.rb, line 27
def self.dump_json(data)
  ActiveSupport::JSON.encode(data)
end
load_json(data) click to toggle source
# File lib/flapjack.rb, line 23
def self.load_json(data)
  ActiveSupport::JSON.decode(data)
end
logger() click to toggle source
# File lib/flapjack/logger.rb, line 21
def logger
  Thread.current[:flapjack_logger] ||= Flapjack::Logger.new(
    Thread.current[:flapjack_logger_name]   || 'default',
    Thread.current[:flapjack_logger_config] || {}
  )
end
logger=(l) click to toggle source
# File lib/flapjack/logger.rb, line 17
def logger=(l)
  Thread.current[:flapjack_logger] = l
end
redis() click to toggle source

Thread and fiber-local

# File lib/flapjack/redis_proxy.rb, line 12
def redis
  redis_cxn = Thread.current[:flapjack_redis]
  return redis_cxn unless redis_cxn.nil?
  Thread.current[:flapjack_redis] = Flapjack::RedisProxy.new
end
sanitize(str) click to toggle source
# File lib/flapjack.rb, line 31
def self.sanitize(str)
  return str if str.nil? || !str.is_a?(String) || str.valid_encoding?
  return str.scrub('?') if str.respond_to(:scrub)
  str.chars.collect {|c| c.valid_encoding? ? c : '_' }.join
end