class RedisClient::CircuitBreaker

def refresh_state

def refresh_state
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  @lock.synchronize do
    if @errors.last < (now - @error_timeout)
      if @success_threshold > 0
        @state = :half_open
        @successes = 0
      else
        @errors.clear
        @state = :closed
      end
    end
  end
end