콘텐츠로 이동

API: Interface

이 페이지는 Fluxgate 컴포넌트의 동작을 정의하는 핵심 인터페이스를 문서화합니다. 이 인터페이스를 구현하여 자신만의 커스텀 컴포넌트(Window, Tracker, Tripper, Retry, Permit, Listener)를 생성할 수 있습니다.


fluxgate.windows.Window

Bases: ABC

Base class for sliding windows over recent call records.

Subclasses must override record, get_metric, and reset.

record abstractmethod

record(record: Record) -> None
Source code in fluxgate/windows.py
17
18
@abstractmethod
def record(self, record: Record) -> None: ...

get_metric abstractmethod

get_metric() -> Metric
Source code in fluxgate/windows.py
20
21
@abstractmethod
def get_metric(self) -> Metric: ...

reset abstractmethod

reset() -> None
Source code in fluxgate/windows.py
23
24
@abstractmethod
def reset(self) -> None: ...

fluxgate.trackers.Tracker

Bases: ABC

Base class for exception trackers.

Subclasses override __call__. The &/|/~ operators build composite trackers automatically.

__call__ abstractmethod

__call__(exception: Exception) -> bool
Source code in fluxgate/trackers.py
18
19
@abstractmethod
def __call__(self, exception: Exception) -> bool: ...

__and__

__and__(other: Tracker) -> Tracker
Source code in fluxgate/trackers.py
21
22
def __and__(self, other: Tracker) -> Tracker:
    return _And(self, other)

__or__

__or__(other: Tracker) -> Tracker
Source code in fluxgate/trackers.py
24
25
def __or__(self, other: Tracker) -> Tracker:
    return _Or(self, other)

__invert__

__invert__() -> Tracker
Source code in fluxgate/trackers.py
27
28
def __invert__(self) -> Tracker:
    return _Not(self)

fluxgate.trippers.Tripper

Bases: ABC

Base class for tripper conditions.

Subclasses must override __call__. Composite trippers (_And/_Or) override __iter__ to expose their children; a leaf yields itself by default. The & and | operators build composite trippers.

__call__ abstractmethod

__call__(ctx: CallContext) -> bool
Source code in fluxgate/trippers.py
46
47
@abstractmethod
def __call__(self, ctx: CallContext) -> bool: ...

__iter__

__iter__() -> Iterator[Tripper]
Source code in fluxgate/trippers.py
49
50
def __iter__(self) -> Iterator[Tripper]:
    yield self

__and__

__and__(other: Tripper) -> Tripper
Source code in fluxgate/trippers.py
52
53
def __and__(self, other: Tripper) -> Tripper:
    return _And(self, other)

__or__

__or__(other: Tripper) -> Tripper
Source code in fluxgate/trippers.py
55
56
def __or__(self, other: Tripper) -> Tripper:
    return _Or(self, other)

fluxgate.retries.Retry

Bases: ABC

Base class for retry strategies.

Subclasses override __call__ to decide whether the breaker should transition from OPEN to HALF_OPEN at the current moment.

__call__ abstractmethod

__call__(changed_at: float, reopens: int) -> bool
Source code in fluxgate/retries.py
17
18
@abstractmethod
def __call__(self, changed_at: float, reopens: int) -> bool: ...

fluxgate.permits.Permit

Bases: ABC

Base class for permit strategies.

Subclasses override __call__ to decide whether a probe call should be admitted while the breaker is in HALF_OPEN.

__call__ abstractmethod

__call__(changed_at: float) -> bool
Source code in fluxgate/permits.py
17
18
@abstractmethod
def __call__(self, changed_at: float) -> bool: ...

fluxgate.listeners.Listener

Bases: Protocol

Protocol for synchronous circuit breaker listeners.

Any callable with the matching signature satisfies this protocol — a plain function or a class implementing __call__.

__call__

__call__(signal: Signal) -> None
Source code in fluxgate/listeners/base.py
18
def __call__(self, signal: Signal, /) -> None: ...

fluxgate.listeners.AsyncListener

Bases: Protocol

Protocol for asynchronous circuit breaker listeners.

__call__ async

__call__(signal: Signal) -> None
Source code in fluxgate/listeners/base.py
25
async def __call__(self, signal: Signal, /) -> None: ...