Skip to content

Config

Start from fluxgo.DefaultConfig() and change only what you need. NewCircuitBreaker panics when Config.Validate() fails.

cfg := fluxgo.DefaultConfig()
cfg.ThetaBase = 0.5
cfg.RecoveryTimeout = 30 * time.Second
cb := fluxgo.NewCircuitBreaker(fluxgo.Settings{Name: "payments", Config: cfg})
FieldDefaultDescription
Alpha0.3EWMA smoothing factor, 0 < α ≤ 1. Fixed to 0.1–0.3 in the thesis experiments.
WindowSize100Size of the rolling percentile window. Fixed in the thesis experiments.
PercentileTarget95Latency percentile to track: 95 or 99. Fixed at 95 in the thesis experiments.
FieldDefaultDescription
W10.4Weight of the EWMA signal in the degradation ratio
W20.6Weight of the percentile signal. W1 + W2 must equal 1
ThetaBase0.6Baseline failure-rate threshold, 0 < θ ≤ 1
ThetaMin0.05Lower clamp of the adaptive threshold
ThetaMax0.9Upper clamp of the adaptive threshold
FieldDefaultDescription
WarmupDuration30sBaseline capture period; 0 disables warmup
WarmupMaxFailRate0.05Maximum failure rate for a valid baseline capture
RecoveryTimeout60sTime spent Open before moving to Half-Open (> 0)
MinDwellTime5sMinimum time between state transitions; 0 disables the guard
FieldDefaultDescription
MinRequests20Outcomes needed in the window before the failure rate is evaluated; between 1 and WindowSize
HalfOpenMaxRequests1Probe requests admitted while Half-Open (≥ 1)
SlowRequestMargin2.0Calls slower than Pt × margin count as degraded (> 0). Fixed at 2.0 in the thesis experiments.
FieldDefaultDescription
RandomSeed0Optional seed for reproducible benchmark runs

Validate() rejects a config when any of these hold (NaN is always rejected):

  • Alpha is not in (0, 1]
  • WindowSize ≤ 0, or MinRequests is outside [1, WindowSize]
  • PercentileTarget is not 95 or 99
  • W1 or W2 is negative, or W1 + W2 is not 1
  • the bounds do not satisfy 0 < ThetaMin ≤ ThetaMax ≤ 1, or ThetaBase is not in (0, 1]
  • WarmupMaxFailRate is not in (0, 1], or WarmupDuration / MinDwellTime is negative
  • RecoveryTimeout ≤ 0, HalfOpenMaxRequests < 1, or SlowRequestMargin ≤ 0