Module: Stoplight::Domain::_TrafficRecovery

Included in:
TrafficRecovery::ConsecutiveSuccesses
Defined in:
sig/_private/stoplight/domain/ports/traffic_recovery.rbs

Overview

Strategies for determining how to recover traffic flow through the Stoplight. These strategies evaluate recovery metrics to decide which color the Stoplight should transition to during the recovery process.

Examples:

Creating a custom traffic recovery strategy

class GradualRecovery
  def initialize(min_success_rate: 0.8, min_samples: 100)
    @min_success_rate = min_success_rate
    @min_samples = min_samples
  end

  def determine_color(config, metrics)
    total_probes = metrics.recovery_probe_successes + metrics.recovery_probe_errors

    if total_probes < @min_samples
      return Color::YELLOW # Keep recovering, not enough samples
    end

    success_rate = metrics.recovery_probe_successes.fdiv(total_probes)
    if success_rate >= @min_success_rate
      Color::GREEN # Recovery successful
    elsif success_rate <= 0.2
      Color::RED # Recovery failed, too many errors
    else
      Color::YELLOW # Continue recovery
    end
  end
end

Instance Method Summary collapse

Instance Method Details

#==Boolean

Object methods

Parameters:

  • (Object)

Returns:

  • (Boolean)


43
# File 'sig/_private/stoplight/domain/ports/traffic_recovery.rbs', line 43

def ==: (untyped) -> bool

#check_compatibilityCompatibilityResult

Checks if the strategy is compatible with the given Stoplight configuration.

Parameters:

Returns:



36
# File 'sig/_private/stoplight/domain/ports/traffic_recovery.rbs', line 36

def check_compatibility: (Config) -> CompatibilityResult

#determine_colordecision

Determines the appropriate recovery state based on the Stoplight's current metrics and recovery progress.

Parameters:

Returns:

  • (decision)


40
# File 'sig/_private/stoplight/domain/ports/traffic_recovery.rbs', line 40

def determine_color: (Config, Domain::MetricsSnapshot) -> decision

#is_a?Boolean

Parameters:

  • (Object)

Returns:

  • (Boolean)


44
# File 'sig/_private/stoplight/domain/ports/traffic_recovery.rbs', line 44

def is_a?: (untyped) -> bool