Class: Resque::StuckQueue::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/resque_stuck_queue/config.rb

Defined Under Namespace

Classes: NoConfigError

Constant Summary collapse

OPTIONS_DESCRIPTIONS =
{
  :triggered_handler            => "set to what gets triggered when resque-stuck-queue will detect the latest heartbeat is older than the trigger_timeout time setting.\n\tExample:\n\tResque::StuckQueue.config[:triggered_handler] = proc { |queue_name, lagtime| send_email('queue \#{queue_name} isnt working, aaah the daemons') }",
  :recovered_handler  => "set to what gets triggered when resque-stuck-queue has triggered a problem, but then detects the queue went back down to functioning well again(before the next trigger).\n\tExample:\n\tResque::StuckQueue.config[:recovered_handler] = proc { |queue_name, lagtime| send_email('phew, queue \#{queue_name} is ok') }",
  :heartbeat          => "set to how often to push that 'heartbeat' job to refresh the latest time it worked.\n\tExample:\n\tResque::StuckQueue.config[:heartbeat] = 5.minutes",
  :trigger_timeout    => "set to how much of a resque work lag you are willing to accept before being notified. note: take the :heartbeat setting into account when setting this timeout.\n\tExample:\n\tResque::StuckQueue.config[:trigger_timeout] = 55.minutes",
  :redis              => "set the Redis instance StuckQueue will use",
  :heartbeat_key      => "optional, name of keys to keep track of the last good resque heartbeat time",
  :triggered_key      => "optional, name of keys to keep track of the last trigger time",
  :logger             => "optional, pass a Logger. Default a ruby logger will be instantiated. Needs to respond to that interface.",
  :queues             => "optional, monitor specific queues you want to send a heartbeat/monitor to. default is :app",
  :abort_on_exception => "optional, if you want the resque-stuck-queue threads to explicitly raise, default is false",
  :refresh_job        => "optional, your own custom refreshing job. if you are using something other than resque",
}
OPTIONS =
OPTIONS_DESCRIPTIONS.keys

Instance Method Summary collapse

Instance Method Details

#[](k) ⇒ Object



38
39
40
41
# File 'lib/resque_stuck_queue/config.rb', line 38

def [](k)
  validate_key_exists!(k)
  super(k)
end

#[]=(k, v) ⇒ Object



33
34
35
36
# File 'lib/resque_stuck_queue/config.rb', line 33

def []=(k,v)
  validate_key_exists!(k)
  super(k,v)
end

#description_for(k) ⇒ Object



51
52
53
# File 'lib/resque_stuck_queue/config.rb', line 51

def description_for(k)
  OPTIONS_DESCRIPTIONS[k.to_sym]
end

#pretty_descriptions ⇒ Object



55
56
57
58
59
60
61
# File 'lib/resque_stuck_queue/config.rb', line 55

def pretty_descriptions
  out = "\n"
  OPTIONS_DESCRIPTIONS.map{|key,msg|
    out << "#{key}:\n\t#{msg}\n\n"
  }
  out
end

#validate_key_exists!(k) ⇒ Object



45
46
47
48
49
# File 'lib/resque_stuck_queue/config.rb', line 45

def validate_key_exists!(k)
  if ! OPTIONS.include?(k)
    raise NoConfigError, "no such config key #{k} exists!"
  end
end