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.



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

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 (Float)

    The unix timestamp for the run, from Faulty.current_time

  • 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



97
98
99
# File 'lib/faulty/storage/null.rb', line 97

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



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

def history(_circuit)
  []
end

#listArray<String>

Returns:

  • (Array<String>)


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

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



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

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 (Float)

    The timestamp the circuit was opened at, from Faulty.current_time

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 (Float)

    The timestamp the circuit was opened at, from Faulty.current_time

  • previous_opened_at (Float)

    The last known value of opened_at. Can be used to compare-and-set. Always non-nil — Circuit#failure! only enters the reopen branch when status.half_open? is true, which requires non-nil opened_at. Unlike previous_reserved_at on #reserve, there is no legitimate "no prior value" call path to reopen, so backends may treat this parameter as required and are not expected to handle nil.

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

#reserve(_circuit, _reserved_at, _previous_reserved_at) ⇒ Boolean

Returns True if the caller may proceed with the half-open test run; false if another caller already holds the reservation.

Parameters:

  • circuit (Circuit)

    The circuit to reserve

  • reserved_at (Float)

    The timestamp of this reservation, from Faulty.current_time

  • previous_reserved_at (Float, nil)

    The last known value of reserved_at, or nil for the first reservation in a new open cycle. Can be used to compare-and-set.

Returns:

  • (Boolean)

    True if the caller may proceed with the half-open test run; false if another caller already holds the reservation.



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

def reserve(_circuit, _reserved_at, _previous_reserved_at)
  true
end

#reset(_circuit) ⇒ void

This method returns an undefined value.

Parameters:

  • circuit (Circuit)

    The circuit to unlock



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

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



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

def status(circuit)
  stub_status(circuit)
end

#unlock(_circuit) ⇒ void

This method returns an undefined value.

Parameters:

  • circuit (Circuit)

    The circuit to unlock



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

def unlock(_circuit)
end