Start from fluxgo.DefaultConfig() and change only what you need.
NewCircuitBreaker panics when Config.Validate() fails.
cfg := fluxgo.DefaultConfig()
cfg.RecoveryTimeout = 30 * time.Second
cb := fluxgo.NewCircuitBreaker(fluxgo.Settings{Name: "payments", Config: cfg})
| Field | Default | Description |
|---|
Alpha | 0.3 | EWMA smoothing factor, 0 < α ≤ 1. Fixed to 0.1–0.3 in the thesis experiments. |
WindowSize | 100 | Size of the rolling percentile window. Fixed in the thesis experiments. |
PercentileTarget | 95 | Latency percentile to track: 95 or 99. Fixed at 95 in the thesis experiments. |
| Field | Default | Description |
|---|
W1 | 0.4 | Weight of the EWMA signal in the degradation ratio |
W2 | 0.6 | Weight of the percentile signal. W1 + W2 must equal 1 |
ThetaBase | 0.6 | Baseline failure-rate threshold, 0 < θ ≤ 1 |
ThetaMin | 0.05 | Lower clamp of the adaptive threshold |
ThetaMax | 0.9 | Upper clamp of the adaptive threshold |
| Field | Default | Description |
|---|
WarmupDuration | 30s | Baseline capture period; 0 disables warmup |
WarmupMaxFailRate | 0.05 | Maximum failure rate for a valid baseline capture |
RecoveryTimeout | 60s | Time spent Open before moving to Half-Open (> 0) |
MinDwellTime | 5s | Minimum time between state transitions; 0 disables the guard |
| Field | Default | Description |
|---|
MinRequests | 20 | Outcomes needed in the window before the failure rate is evaluated; between 1 and WindowSize |
HalfOpenMaxRequests | 1 | Probe requests admitted while Half-Open (≥ 1) |
SlowRequestMargin | 2.0 | Calls slower than Pt × margin count as degraded (> 0). Fixed at 2.0 in the thesis experiments. |
| Field | Default | Description |
|---|
RandomSeed | 0 | Optional 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