proxywhirl.circuit_breaker.base

Base circuit breaker implementation with shared state machine logic.

This module provides the core state machine logic shared between sync (CircuitBreaker) and async (AsyncCircuitBreaker) implementations.

Classes

CircuitBreakerBase

Base circuit breaker with shared state machine logic.

CircuitBreakerState

Circuit breaker states.

Module Contents

class proxywhirl.circuit_breaker.base.CircuitBreakerBase(/, **data)[source]

Bases: pydantic.BaseModel

Base circuit breaker with shared state machine logic.

This class contains all the state management logic shared between sync and async implementations. Subclasses provide the locking mechanism.

Parameters:

data (Any)

proxy_id[source]

Unique identifier for the proxy

state[source]

Current circuit breaker state (CLOSED, OPEN, HALF_OPEN)

failure_count[source]

Number of failures in current window

failure_threshold[source]

Number of failures before opening circuit

window_duration[source]

Rolling window duration in seconds

timeout_duration[source]

How long circuit stays open before testing recovery

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

class proxywhirl.circuit_breaker.base.CircuitBreakerState[source]

Bases: str, enum.Enum

Circuit breaker states.

Initialize self. See help(type(self)) for accurate signature.