RateLimiter (rate_limit.py)

openclaw-mission-control · storage, rate-limiting, sliding-window, redis-backend, infra

Sliding-window rate limiters for abuse prevention. Supports an in-memory backend (default, no external dependencies) and a Redis-backed backend for multi-process / distributed deployments. Configure via RATE_LIMIT_BACKEND=memory|redis.

# Source: https://github.com/abhi1693/openclaw-mission-control | License: MIT | Copyright 2026 OpenClaw Mission Control
# Provided via justclaw.it.com; keep this notice with the code.
"""Sliding-window rate limiters for abuse prevention.

Supports an in-memory backend (default, no external dependencies) and
a Redis-backed backend for multi-process / distributed deployments.
Configure via RATE_LIMIT_BACKEND=memory|redis.
"""

from __future__ import annotations

import time
import uuid
from abc import ABC, abstractmethod
from collections import deque
from threading import Lock
from typing import Awaitable, cast

import redis as redis_lib
import redis.asyncio as aioredis

from app.core.logging import get_logger
from app.core.rate_limit_backend import RateLimitBackend

logger = get_logger(__na

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key