Class: Faulty::Storage::Null

Inherits:
Object
  • Object
show all
Defined in:
lib/faulty/storage/null.rb

Overview

A no-op backend for disabling circuits

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.newObject



10
11
12
# File 'lib/faulty/storage/null.rb', line 10

def self.new
  @instance
end

Instance Method Details

#clearvoid

This method returns an undefined value.



84
85
# File 'lib/faulty/storage/null.rb', line 84

def clear
end

#close(_circuit) ⇒ Boolean

Returns True if the circuit transitioned from open to closed.

Returns:

  • (Boolean)

    True if the circuit transitioned from open to closed



45
46
47
# File 'lib/faulty/storage/null.rb', line 45

def close(_circuit)
  true
end

#entry(circuit, _time, _success, status) ⇒ Status?

Returns If status is not nil, the updated status object.

Parameters:

  • circuit (Circuit)

    The circuit that ran

  • time (Integer)

    The unix timestamp for the run

  • success (Boolean)

    True if the run succeeded

  • status (Status, nil)

    The previous status. If given, this method must return an updated status object from the new entry data.

Returns:

  • (Status, nil)

    If status is not nil, the updated status object.



27
28
29
# File 'lib/faulty/storage/null.rb', line 27

def entry(circuit, _time, _success, status)
  stub_status(circuit) if status
end

#fault_tolerant?Boolean

This backend is fault tolerant

Returns:

  • (Boolean)
  • (Boolean)

    True if this cache backend is fault tolerant



91
92
93
# File 'lib/faulty/storage/null.rb', line 91

def fault_tolerant?
  true
end

#get_options(_circuit) ⇒ Hash

Returns A hash of the options stored by #set_options. The keys must be symbols.

Returns:

  • (Hash)

    A hash of the options stored by #set_options. The keys must be symbols.



16
17
18
# File 'lib/faulty/storage/null.rb', line 16

def get_options(_circuit)
  {}
end

#history(_circuit) ⇒ Array<Array>

Returns An array of history tuples.

Parameters:

  • circuit (Circuit)

    The circuit to get history for

Returns:

  • (Array<Array>)

    An array of history tuples



72
73
74
# File 'lib/faulty/storage/null.rb', line 72

def history(_circuit)
  []
end

#listArray<String>

Returns:

  • (Array<String>)


78
79
80
# File 'lib/faulty/storage/null.rb', line 78

def list
  []
end

#lock(_circuit, _state) ⇒ void

This method returns an undefined value.

Parameters:

  • circuit (Circuit)

    The circuit to lock

  • state (:open, :closed)

    The state to lock the circuit in



51
52
# File 'lib/faulty/storage/null.rb', line 51

def lock(_circuit, _state)
end

#open(_circuit, _opened_at) ⇒ Boolean

Returns True if the circuit transitioned from closed to open.

Parameters:

  • circuit (Circuit)

    The circuit to open

  • opened_at (Integer)

    The timestmp the circuit was opened at

Returns:

  • (Boolean)

    True if the circuit transitioned from closed to open



33
34
35
# File 'lib/faulty/storage/null.rb', line 33

def open(_circuit, _opened_at)
  true
end

#reopen(_circuit, _opened_at, _previous_opened_at) ⇒ Boolean

Returns True if the opened_at time was updated.

Parameters:

  • circuit (Circuit)

    The circuit to reopen

  • opened_at (Integer)

    The timestmp the circuit was opened at

  • previous_opened_at (Integer)

    The last known value of opened_at. Can be used to comare-and-set.

Returns:

  • (Boolean)

    True if the opened_at time was updated



39
40
41
# File 'lib/faulty/storage/null.rb', line 39

def reopen(_circuit, _opened_at, _previous_opened_at)
  true
end

#reset(_circuit) ⇒ void

This method returns an undefined value.

Parameters:

  • circuit (Circuit)

    The circuit to unlock



61
62
# File 'lib/faulty/storage/null.rb', line 61

def reset(_circuit)
end

#set_options(_circuit, _stored_options) ⇒ void

This method returns an undefined value.

Parameters:

  • circuit (Circuit)

    The circuit to set options for

  • stored_options (Hash<Symbol, Object>)

    A hash of symbol option names to circuit options. These option values are guranteed to be primive values.



22
23
# File 'lib/faulty/storage/null.rb', line 22

def set_options(_circuit, _stored_options)
end

#status(circuit) ⇒ Status

Returns The current status.

Parameters:

  • circuit (Circuit)

    The circuit to get status for

Returns:

  • (Status)

    The current status



66
67
68
# File 'lib/faulty/storage/null.rb', line 66

def status(circuit)
  stub_status(circuit)
end

#unlock(_circuit) ⇒ void

This method returns an undefined value.

Parameters:

  • circuit (Circuit)

    The circuit to unlock



56
57
# File 'lib/faulty/storage/null.rb', line 56

def unlock(_circuit)
end