Class: Stoplight::Domain::Tracker::Request Private

Inherits:
Base
  • Object
show all
Defined in:
lib/stoplight/domain/tracker/request.rb,
sig/_private/stoplight/domain/tracker/request.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.

Tracks request outcomes (success/failure) and manages state transitions for normal traffic.

Used by GreenRunStrategy to track failures and potentially open the circuit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(traffic_control:, notifiers:, config:, metrics_store:, state_store:) ⇒ Request

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



13
14
15
16
17
18
19
# File 'lib/stoplight/domain/tracker/request.rb', line 13

def initialize(traffic_control:, notifiers:, config:, metrics_store:, state_store:)
  @traffic_control = traffic_control
  @notifiers = notifiers
  @config = config
  @metrics_store = metrics_store
  @state_store = state_store
end

Instance Attribute Details

#configConfig (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.

Returns:



34
35
36
# File 'lib/stoplight/domain/tracker/request.rb', line 34

def config
  @config
end

#metrics_store_MetricsStore (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.

Returns:



35
36
37
# File 'lib/stoplight/domain/tracker/request.rb', line 35

def metrics_store
  @metrics_store
end

#notifiersArray[state_transition_notifier] (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.

Returns:

  • (Array[state_transition_notifier])


33
34
35
# File 'lib/stoplight/domain/tracker/request.rb', line 33

def notifiers
  @notifiers
end

#state_store_StateStore (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.

Returns:



36
37
38
# File 'lib/stoplight/domain/tracker/request.rb', line 36

def state_store
  @state_store
end

#traffic_control_TrafficControl (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.

Returns:



32
33
34
# File 'lib/stoplight/domain/tracker/request.rb', line 32

def traffic_control
  @traffic_control
end

Instance Method Details

#record_failure(exception) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • exception (StandardError)


21
22
23
24
25
26
# File 'lib/stoplight/domain/tracker/request.rb', line 21

def record_failure(exception)
  metrics_store.record_failure(exception)
  metrics = metrics_store.metrics_snapshot

  transition_to_red(exception, metrics:)
end

#record_successvoid

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.

This method returns an undefined value.



28
# File 'lib/stoplight/domain/tracker/request.rb', line 28

def record_success = metrics_store.record_success