services.backoff_state module

Persistent GitHub backoff state management.

Backoff is a global switch to reduce GitHub API traffic when nearing rate limits or during maintenance. State is persisted in the DB so it survives restarts, with an in-memory cache for fast reads.

services.backoff_state.emit_event(event, severity='info', **fields)[מקור]
פרמטרים:
class services.backoff_state.BackoffInfo(enabled, reason='', updated_at=datetime.datetime(2026, 4, 3, 21, 41, 16, 872708, tzinfo=datetime.timezone.utc), expires_at=None)[מקור]

Bases: object

פרמטרים:
enabled: bool
reason: str = ''
updated_at: datetime = datetime.datetime(2026, 4, 3, 21, 41, 16, 872708, tzinfo=datetime.timezone.utc)
expires_at: Optional[datetime] = None
is_active()[מקור]
Return type:

bool

__init__(enabled, reason='', updated_at=datetime.datetime(2026, 4, 3, 21, 41, 16, 872708, tzinfo=datetime.timezone.utc), expires_at=None)
פרמטרים:
Return type:

None

class services.backoff_state.BackoffState[מקור]

Bases: object

Backoff state persisted in DB with memory cache.

__init__()[מקור]
Return type:

None

get(refresh=False)[מקור]
Return type:

BackoffInfo

פרמטרים:

refresh (bool)

enable(*, reason='', ttl_minutes=None)[מקור]
Return type:

BackoffInfo

פרמטרים:
  • reason (str)

  • ttl_minutes (int | None)

disable(*, reason='')[מקור]
Return type:

BackoffInfo

פרמטרים:

reason (str)

toggle(*, reason='', ttl_minutes=None)[מקור]
Return type:

BackoffInfo

פרמטרים:
  • reason (str)

  • ttl_minutes (int | None)