API: Tripper¶
이 페이지는 사용 가능한 Tripper를 문서화합니다. Tripper는 window의 Metric을 평가하여 회로가 상태를 변경해야 하는지 결정하는 역할을 합니다.
Tripper 선택 및 조합에 대한 개요는 Tripper 컴포넌트 가이드를 참조하십시오.
fluxgate.trippers.Closed
¶
Bases: TripperBase
Tripper that returns true only when circuit is in CLOSED state.
Used to compose conditions that should only apply when circuit is closed.
Examples:
>>> # Only check failure rate when circuit is closed
>>> tripper = Closed() & FailureRate(0.5)
fluxgate.trippers.HalfOpened
¶
Bases: TripperBase
Tripper that returns true only when circuit is in HALF_OPEN state.
Used to compose conditions that should only apply when circuit is half-open.
Examples:
>>> # Only check failure rate when circuit is half-open
>>> tripper = HalfOpened() & FailureRate(0.3)
fluxgate.trippers.MinRequests
¶
MinRequests(count: int)
Bases: TripperBase
Tripper that requires minimum number of calls before evaluating.
Prevents premature circuit opening when sample size is too small.
Examples:
>>> # Only trip after at least 10 calls
>>> tripper = MinRequests(10) & FailureRate(0.5)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Minimum number of calls required |
required |
Source code in fluxgate/trippers.py
111 112 113 114 | |
fluxgate.trippers.FailureRate
¶
FailureRate(ratio: float)
Bases: TripperBase
Tripper based on failure rate threshold.
Returns true when the ratio of failed calls exceeds the threshold.
Examples:
>>> # Trip when 50% or more calls fail
>>> tripper = FailureRate(0.5)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio
|
float
|
Failure rate threshold (0.0 to 1.0) |
required |
Source code in fluxgate/trippers.py
135 136 137 138 | |
__call__
¶
__call__(
metric: Metric,
_state: StateEnum,
_consecutive_failures: int,
) -> bool
Source code in fluxgate/trippers.py
140 141 142 143 144 145 146 | |
fluxgate.trippers.AvgLatency
¶
AvgLatency(threshold: float)
Bases: TripperBase
Tripper based on average latency threshold.
Returns true when average call duration reaches or exceeds the threshold.
Examples:
>>> # Trip when average latency reaches 2 seconds
>>> tripper = AvgLatency(2.0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
float
|
Latency threshold in seconds |
required |
Source code in fluxgate/trippers.py
162 163 164 165 | |
__call__
¶
__call__(
metric: Metric,
_state: StateEnum,
_consecutive_failures: int,
) -> bool
Source code in fluxgate/trippers.py
167 168 169 170 171 172 173 | |
fluxgate.trippers.SlowRate
¶
SlowRate(ratio: float)
Bases: TripperBase
Tripper based on slow call rate threshold.
Returns true when the ratio of slow calls exceeds the threshold. Slow calls are determined by the circuit breaker's slow_threshold.
Examples:
>>> # Trip when 30% or more calls are slow
>>> tripper = SlowRate(0.3)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio
|
float
|
Slow call rate threshold (0.0 to 1.0) |
required |
Source code in fluxgate/trippers.py
190 191 192 193 | |
__call__
¶
__call__(
metric: Metric,
_state: StateEnum,
_consecutive_failures: int,
) -> bool
Source code in fluxgate/trippers.py
195 196 197 198 199 200 201 | |