API: Permit¶
이 페이지는 사용 가능한 Permit을 문서화합니다. Permit은 HALF_OPEN 상태 동안 서비스 복구를 테스트하기 위해 얼마나 많은 검증 호출이 통과되도록 허용되는지 제어합니다.
Permit 선택에 대한 개요는 Permits 컴포넌트 가이드를 참조하십시오.
fluxgate.permits.All
¶
Bases: IPermit
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
21 22 | |
fluxgate.permits.Random
¶
Random(ratio: float)
Bases: IPermit
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
39 40 41 42 | |
__call__
¶
__call__(_changed_at: float) -> bool
Source code in fluxgate/permits.py
44 45 | |
fluxgate.permits.RampUp
¶
RampUp(initial: float, final: float, duration: float)
Bases: IPermit
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 (0.0 to 1.0) |
required |
final
|
float
|
Final permit ratio (0.0 to 1.0, must be >= initial) |
required |
duration
|
float
|
Ramp-up duration in seconds |
required |
Source code in fluxgate/permits.py
64 65 66 67 68 69 70 71 | |
__call__
¶
__call__(changed_at: float) -> bool
Source code in fluxgate/permits.py
73 74 75 76 77 78 79 80 | |