API: Permits¶
This page documents the available recovery permit strategies. Permit strategies control how many "probe" calls are allowed to pass through during the HALF_OPEN state to test for service recovery.
For a high-level guide on choosing a permit strategy, see the Permits Component Guide.
fluxgate.permits.All
¶
Bases: Permit
Permit strategy that always allows calls.
Useful for testing or when you want all calls to pass through in HALF_OPEN state.
Examples:
>>> permit = All()
__call__
¶
__call__(_changed_at: float) -> bool
Source code in fluxgate/permits.py
31 32 | |
fluxgate.permits.Random
¶
Random(ratio: float)
Bases: Permit
Permit strategy with random sampling in HALF_OPEN state.
Allows calls randomly based on a fixed probability ratio. Simple and effective for limiting concurrent calls during recovery.
Examples:
>>> # Allow 50% of calls in HALF_OPEN state
>>> permit = Random(ratio=0.5)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio
|
float
|
Probability of allowing a call (0.0 to 1.0) |
required |
Source code in fluxgate/permits.py
49 50 51 52 | |
__call__
¶
__call__(_changed_at: float) -> bool
Source code in fluxgate/permits.py
54 55 | |
fluxgate.permits.RampUp
¶
RampUp(initial: float, final: float, duration: float)
Bases: Permit
Permit strategy that gradually increases allowed traffic over time.
Starts with a low permit ratio and gradually increases to the final ratio over the specified duration. Useful for smooth recovery without sudden load spikes.
Examples:
>>> # Start at 10%, ramp up to 80% over 60 seconds
>>> permit = RampUp(initial=0.1, final=0.8, duration=60.0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial
|
float
|
Initial permit ratio, strictly greater than 0.0 and at most
|
required |
final
|
float
|
Final permit ratio (initial to 1.0) |
required |
duration
|
float
|
Ramp-up duration in seconds |
required |
Source code in fluxgate/permits.py
76 77 78 79 80 81 82 83 84 85 | |
__call__
¶
__call__(changed_at: float) -> bool
Source code in fluxgate/permits.py
87 88 89 90 91 92 93 94 | |