Class: Stoplight::Wiring::StorageSetBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stoplight/wiring/storage_set_builder.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.

Assembles a StorageSet from a backend, selecting windowed or unbounded metrics.

StorageSetBuilder is the single point where the windowed/unbounded decision is made. All other storage components (state, recovery lock, recovery metrics) are backend-specific but mode-independent.

Examples:

Windowed metrics (error rate tracking)

builder = StorageSetBuilder.new(backend: redis_backend, windowed: true)
storage = builder.build
storage.metrics_store #=> FailSafe<WindowMetrics>

Unbounded metrics (consecutive error tracking)

builder = StorageSetBuilder.new(backend: memory_backend, windowed: false)
storage = builder.build
storage.metrics_store #=> UnboundedMetrics

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backend:, windowed:) ⇒ StorageSetBuilder

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 StorageSetBuilder.



28
29
30
31
# File 'lib/stoplight/wiring/storage_set_builder.rb', line 28

def initialize(backend:, windowed:)
  @backend = backend
  @windowed = windowed
end

Instance Attribute Details

#backendObject (readonly)

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
# File 'lib/stoplight/wiring/storage_set_builder.rb', line 25

def backend
  @backend
end

#windowedObject (readonly)

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.



26
27
28
# File 'lib/stoplight/wiring/storage_set_builder.rb', line 26

def windowed
  @windowed
end

Instance Method Details

#buildObject

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.



33
34
35
36
37
38
39
40
# File 'lib/stoplight/wiring/storage_set_builder.rb', line 33

def build
  StorageSet.new(
    metrics_store:,
    recovery_metrics_store: backend.recovery_metrics_store,
    state_store: backend.state_store,
    recovery_lock_store: backend.recovery_lock_store
  )
end