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.
-
#options ⇒ Object
Returns the value of attribute options.
-
#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.
45 46 47 48 49 50 |
# File 'lib/faulty/storage/memory.rb', line 45 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
44 45 46 |
# File 'lib/faulty/storage/memory.rb', line 44 def lock @lock end |
#opened_at ⇒ Object
Returns the value of attribute opened_at
44 45 46 |
# File 'lib/faulty/storage/memory.rb', line 44 def opened_at @opened_at end |
#options ⇒ Object
Returns the value of attribute options
44 45 46 |
# File 'lib/faulty/storage/memory.rb', line 44 def @options end |
#runs ⇒ Object
Returns the value of attribute runs
44 45 46 |
# File 'lib/faulty/storage/memory.rb', line 44 def runs @runs end |
#state ⇒ Object
Returns the value of attribute state
44 45 46 |
# File 'lib/faulty/storage/memory.rb', line 44 def state @state end |
Instance Method Details
#status(circuit_options) ⇒ Status
Create a status object from the current circuit state
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/faulty/storage/memory.rb', line 56 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 |