Skip to content

latent.rate_limiter.backends

Backend factory — picks the active rate-limiter implementation at import time.

Default is the SQLite IPC backend (single-host multi-process). Switch via LATENT_RATE_LIMIT_BACKEND:

  • sqlite_ipc (default): single-host multi-process cap via SQLite + WAL.
  • disabled: no-op — bypasses rate limiting entirely. Use in production hot paths where the per-call SQLite round-trip + semaphore wait is unjustified. Eval / batch pipelines should leave the default.
  • redis: multi-host cap (not yet implemented; follow-up PR).

Functions

get_default_backend

get_default_backend() -> RateLimiterBackend

Return the process-wide rate-limiter backend.

Cached: the same instance is returned for every call so all callers share the same in-memory connection pool / SQLite handle map. Reset with get_default_backend.cache_clear() in tests.