Class: Faulty::Storage::Memory::MemoryCircuit
- Inherits:
-
Struct
- Object
- Struct
- Faulty::Storage::Memory::MemoryCircuit
- Defined in:
- lib/faulty/storage/memory.rb
Overview
The internal object for storing a circuit
Instance Attribute Summary collapse
-
#lock ⇒ Object
Returns the value of attribute lock.
-
#opened_at ⇒ Object
Returns the value of attribute opened_at.
-
#runs ⇒ Object
Returns the value of attribute runs.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize ⇒ MemoryCircuit
constructor
A new instance of MemoryCircuit.
-
#status(circuit_options) ⇒ Status
Create a status object from the current circuit state.
Constructor Details
#initialize ⇒ MemoryCircuit
Returns a new instance of MemoryCircuit.
47 48 49 50 51 52 |
# File 'lib/faulty/storage/memory.rb', line 47 def initialize self.state = Concurrent::Atom.new(:closed) self.runs = Concurrent::MVar.new([], dup_on_deref: true) self.opened_at = Concurrent::Atom.new(nil) self.lock = nil end |
Instance Attribute Details
#lock ⇒ Object
Returns the value of attribute lock
46 47 48 |
# File 'lib/faulty/storage/memory.rb', line 46 def lock @lock end |
#opened_at ⇒ Object
Returns the value of attribute opened_at
46 47 48 |
# File 'lib/faulty/storage/memory.rb', line 46 def opened_at @opened_at end |
#runs ⇒ Object
Returns the value of attribute runs
46 47 48 |
# File 'lib/faulty/storage/memory.rb', line 46 def runs @runs end |
#state ⇒ Object
Returns the value of attribute state
46 47 48 |
# File 'lib/faulty/storage/memory.rb', line 46 def state @state end |
Instance Method Details
#status(circuit_options) ⇒ Status
Create a status object from the current circuit state
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/faulty/storage/memory.rb', line 58 def status() status = nil runs.borrow do |locked_runs| status = Faulty::Status.from_entries( locked_runs, state: state.value, lock: lock, opened_at: opened_at.value, options: ) end status end |