Class: Stoplight::Wiring::Memory::Backend Private

Inherits:
DataStoreBackend show all
Defined in:
lib/stoplight/wiring/memory/backend.rb

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.

In-memory storage backend for single-process deployments.

All storage components use thread-safe in-memory data structures. State is not shared across processes and is lost on restart.

Memory backend is also used as the fallback layer for Redis backend when Redis is unavailable.

Examples:

backend = Memory::Backend.new(clock: SystemClock.new, config:)
backend.state_store #=> Memory::Storage::State

Instance Method Summary collapse

Constructor Details

#initialize(clock:, config:) ⇒ 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.



20
21
22
23
# File 'lib/stoplight/wiring/memory/backend.rb', line 20

def initialize(clock:, config:)
  @clock = clock
  @config = config
end

Instance Method Details

#recovery_lock_storeObject

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.



32
33
34
# File 'lib/stoplight/wiring/memory/backend.rb', line 32

def recovery_lock_store
  @recovery_lock_store ||= Infrastructure::Memory::Storage::RecoveryLock.new
end

#recovery_metrics_storeObject

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.



36
37
38
39
40
# File 'lib/stoplight/wiring/memory/backend.rb', line 36

def recovery_metrics_store
  @recovery_metrics_store ||= Infrastructure::Memory::Storage::RecoveryMetrics.new(
    clock: @clock
  )
end

#state_storeObject

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.



25
26
27
28
29
30
# File 'lib/stoplight/wiring/memory/backend.rb', line 25

def state_store
  @state_store ||= Infrastructure::Memory::Storage::State.new(
    clock: @clock,
    cool_off_time: @config.cool_off_time
  )
end

#unbounded_metrics_storeObject

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.



49
50
51
52
53
# File 'lib/stoplight/wiring/memory/backend.rb', line 49

def unbounded_metrics_store
  @unbounded_metrics_store ||= Infrastructure::Memory::Storage::UnboundedMetrics.new(
    clock: @clock
  )
end

#windowed_metrics_storeObject

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
# File 'lib/stoplight/wiring/memory/backend.rb', line 42

def windowed_metrics_store
  @windowed_metrics_store ||= Infrastructure::Memory::Storage::WindowMetrics.new(
    window_size: T.must(@config.window_size),
    clock: @clock
  )
end