Class: Stoplight::Wiring::Redis::Backend Private
- Inherits:
-
DataStoreBackend
- Object
- DataStoreBackend
- Stoplight::Wiring::Redis::Backend
- Defined in:
- lib/stoplight/wiring/redis/backend.rb,
sig/_private/stoplight/wiring/redis/backend.rbs
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Redis storage backend with automatic failover to in-memory storage.
Every storage component is wrapped in a FailSafe decorator that catches Redis connection errors and falls back to a Memory backend. This ensures circuit breakers remain functional even when Redis is unavailable.
The failover behavior is coordinated through a dedicated circuit breaker
(failover_light) that prevents repeated Redis connection attempts during
an outage.
Instance Method Summary collapse
-
#initialize(redis:, scripting:, key_space:, config:, error_notifier:, failover_light:, clock:) ⇒ Backend
constructor
private
A new instance of Backend.
- #recovery_lock_store ⇒ Infrastructure::FailSafe::Storage::RecoveryLock private
- #recovery_metrics_store ⇒ Infrastructure::FailSafe::Storage::Metrics private
- #state_stare ⇒ Infrastructure::FailSafe::Storage::State private
- #state_store ⇒ Object private
- #unbounded_metrics_store ⇒ Infrastructure::FailSafe::Storage::Metrics private
- #windowed_metrics_store ⇒ Infrastructure::FailSafe::Storage::Metrics private
Constructor Details
#initialize(redis:, scripting:, key_space:, config:, error_notifier:, failover_light:, clock:) ⇒ Backend
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Backend.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/stoplight/wiring/redis/backend.rb', line 31 def initialize(redis:, scripting:, key_space:, config:, error_notifier:, failover_light:, clock:) @redis = redis @scripting = scripting @key_space = key_space @clock = clock @config = config @error_notifier = error_notifier @failover_light = failover_light @memory_fallback = Memory::Backend.new(clock:, config:) end |
Instance Method Details
#recovery_lock_store ⇒ Infrastructure::FailSafe::Storage::RecoveryLock
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/stoplight/wiring/redis/backend.rb', line 57 def recovery_lock_store @recovery_lock_store ||= Infrastructure::FailSafe::Storage::RecoveryLock.new( primary_store: Infrastructure::Redis::Storage::RecoveryLock.new( config: @config, # TODO: pass cool_off_time directly redis: @redis, scripting: @scripting, key_space: @key_space ), error_notifier: @error_notifier, failover_store: @memory_fallback.recovery_lock_store, circuit_breaker: @failover_light ) end |
#recovery_metrics_store ⇒ Infrastructure::FailSafe::Storage::Metrics
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/stoplight/wiring/redis/backend.rb', line 71 def recovery_metrics_store @recovery_metrics_store ||= Infrastructure::FailSafe::Storage::Metrics.new( error_notifier: @error_notifier, primary_store: Infrastructure::Redis::Storage::RecoveryMetrics.new( clock: @clock, redis: @redis, scripting: @scripting, key_space: @key_space ), failover_store: @memory_fallback.recovery_metrics_store, circuit_breaker: @failover_light ) end |
#state_stare ⇒ Infrastructure::FailSafe::Storage::State
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 |
# File 'sig/_private/stoplight/wiring/redis/backend.rbs', line 30
def state_stare: -> Infrastructure::FailSafe::Storage::State
|
#state_store ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stoplight/wiring/redis/backend.rb', line 42 def state_store @state_store ||= Infrastructure::FailSafe::Storage::State.new( primary_store: Infrastructure::Redis::Storage::State.new( redis: @redis, scripting: @scripting, key_space: @key_space, cool_off_time: @config.cool_off_time, clock: @clock ), error_notifier: @error_notifier, failover_store: @memory_fallback.state_store, circuit_breaker: @failover_light ) end |
#unbounded_metrics_store ⇒ Infrastructure::FailSafe::Storage::Metrics
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/stoplight/wiring/redis/backend.rb', line 100 def unbounded_metrics_store @unbounded_metrics_store ||= Infrastructure::FailSafe::Storage::Metrics.new( error_notifier: @error_notifier, primary_store: Infrastructure::Redis::Storage::UnboundedMetrics.new( clock: @clock, redis: @redis, scripting: @scripting, key_space: @key_space ), failover_store: @memory_fallback.unbounded_metrics_store, circuit_breaker: @failover_light ) end |
#windowed_metrics_store ⇒ Infrastructure::FailSafe::Storage::Metrics
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/stoplight/wiring/redis/backend.rb', line 85 def windowed_metrics_store @windowed_metrics_store ||= Infrastructure::FailSafe::Storage::Metrics.new( error_notifier: @error_notifier, primary_store: Infrastructure::Redis::Storage::WindowMetrics.new( config: @config, # TODO: pass window size directly redis: @redis, scripting: @scripting, clock: @clock, key_space: @key_space ), failover_store: @memory_fallback.windowed_metrics_store, circuit_breaker: @failover_light ) end |