class Monitors::ViolationsRecorders::Base

Public Class Methods

inherited(base) click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 12
def inherited(base)
  base.instance_variable_set(:@violations, {})
end
is_violating?(process) click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 22
def is_violating?(process)
  log "checking #{process}", :debug
  update_violations_count(process)
  log "#{@violations}", :debug
  violating = @violations[process.send(process_attr)] == retries_limit
  @violations[process.send(process_attr)] = 0 if violating
  violating
end
reset() click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 18
def reset
  @violations = {}
end

Protected Class Methods

process_attr() click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 46
def process_attr
  raise NotImplementedError
end
process_is_violating?(process) click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 50
def process_is_violating?(process)
  raise NotImplementedError
end
retries_limit() click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 42
def retries_limit
  raise NotImplementedError
end
update_violations_count(process) click to toggle source
# File lib/monitors/violations_recorders/base.rb, line 33
def update_violations_count(process)
  @violations[process.send(process_attr)] ||= 0
  if process_is_violating?(process)
    @violations[process.send(process_attr)]+= 1 
  else
    @violations[process.send(process_attr)] = 0
  end
end