Class: Seekmodo::Sdk::Storage::Memory::BreakerStore
- Inherits:
-
Object
- Object
- Seekmodo::Sdk::Storage::Memory::BreakerStore
- Includes:
- Protocols::BreakerStateStore
- Defined in:
- lib/seekmodo/sdk/storage/memory/stores.rb
Instance Method Summary collapse
-
#initialize ⇒ BreakerStore
constructor
A new instance of BreakerStore.
- #load(key) ⇒ Object
- #save(key, state, ttl_seconds) ⇒ Object
Constructor Details
#initialize ⇒ BreakerStore
Returns a new instance of BreakerStore.
19 20 21 |
# File 'lib/seekmodo/sdk/storage/memory/stores.rb', line 19 def initialize @rows = {} end |
Instance Method Details
#load(key) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/seekmodo/sdk/storage/memory/stores.rb', line 23 def load(key) state = @rows[key] return DEFAULT_BREAKER_STATE.dup unless state { "state" => state["state"], "failures" => state["failures"].dup, "opened_at" => state["opened_at"].to_i, "probe_in_flight" => state["probe_in_flight"] } end |
#save(key, state, ttl_seconds) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/seekmodo/sdk/storage/memory/stores.rb', line 35 def save(key, state, ttl_seconds) @rows[key] = { "state" => state["state"], "failures" => state["failures"].dup, "opened_at" => state["opened_at"].to_i, "probe_in_flight" => state["probe_in_flight"] } end |