class Stoplight::DataStore::Memory

@see Base

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/stoplight/data_store/memory.rb, line 11
def initialize
  @failures = Hash.new { |h, k| h[k] = [] }
  @states = Hash.new { |h, k| h[k] = State::UNLOCKED }
  super() # MonitorMixin
end

Public Instance Methods

clear_failures(light) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 37
def clear_failures(light)
  synchronize { @failures.delete(light.name) }
end
clear_state(light) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 49
def clear_state(light)
  synchronize { @states.delete(light.name) }
end
get_all(light) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 21
def get_all(light)
  synchronize { [@failures[light.name], @states[light.name]] }
end
get_failures(light) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 25
def get_failures(light)
  synchronize { @failures[light.name] }
end
get_state(light) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 41
def get_state(light)
  synchronize { @states[light.name] }
end
names() click to toggle source
# File lib/stoplight/data_store/memory.rb, line 17
def names
  synchronize { @failures.keys | @states.keys }
end
record_failure(light, failure) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 29
def record_failure(light, failure)
  synchronize do
    n = light.threshold - 1
    @failures[light.name] = @failures[light.name].first(n)
    @failures[light.name].unshift(failure).size
  end
end
set_state(light, state) click to toggle source
# File lib/stoplight/data_store/memory.rb, line 45
def set_state(light, state)
  synchronize { @states[light.name] = state }
end