ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

Track rate-limit counters in process-local memory.

Method __atCapacity Report whether admitting a new client would exceed either bound.
Method __gc Inspect the next group of keys and remove expired buckets.
Method __hit Update quota and capacity counters while holding the store lock.
Method __init__ Initialize an empty rate-limit store.
Method __newBucket Create a bucket only when bounded reclamation makes room for it.
Async Method hit Record a request attempt and decide whether it is allowed.
Constant _GC_BATCH_SIZE Gc batch size value used by MemoryRateLimitStore.
Constant _GC_INTERVAL Inspect a bounded group of keys after each group of request attempts.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable __keys Keys produced by deque.
Instance Variable __lock Lock protecting concurrent access to shared state.
Instance Variable __max_events Maximum number of accepted timestamps retained across all clients.
Instance Variable __max_keys Maximum number of retained client buckets.
Instance Variable __storage Entries retained by the in-memory storage backend.
Instance Variable __ticks Ticks value used by MemoryRateLimitStore.
Instance Variable __total_events Total events value used by MemoryRateLimitStore.
def __atCapacity(self) -> bool: (source)

Report whether admitting a new client would exceed either bound.

Returns
boolWhether client or timestamp capacity is exhausted.
def __gc(self, now: float): (source)

Inspect the next group of keys and remove expired buckets.

Parameters
now:floatCurrent monotonic timestamp.
Returns
NoneInspect the next group of keys and remove expired buckets.
def __hit(self, key: str, limit: int, window: int) -> bool: (source)

Update quota and capacity counters while holding the store lock.

Parameters
key:strClient identity whose timestamps are retained.
limit:intMaximum accepted attempts per client window.
window:intSliding-window duration in seconds.
Returns
boolWhether quota and retained-object capacity permit this attempt.
def __init__(self, *, max_keys: int = 10000, max_events: int = 100000): (source)

Initialize an empty rate-limit store.

Parameters
max_keys:int, optionalMaximum number of retained client buckets.
max_events:int, optionalMaximum number of accepted timestamps retained across all clients.
Returns
NoneInitialize an empty rate-limit store.
def __newBucket(self, key: str, now: float, window: int) -> _RateLimitBucket | None: (source)

Create a bucket only when bounded reclamation makes room for it.

Parameters
key:strClient identity to retain.
now:floatCurrent monotonic timestamp.
window:intSliding-window duration in seconds.
Returns
orionis.http.layer.store.memory_rate_limit._RateLimitBucket | NoneNew empty bucket, or None when the store cannot retain more clients.
async def hit(self, key: str, limit: int, window: int) -> bool: (source)

Record a request attempt and decide whether it is allowed.

Implements a sliding window over accepted attempts. Inactive keys are reclaimed incrementally during subsequent attempts, including rejected attempts. Each key should use a consistent window. A lock serializes updates across event loops and threads. Capacity exhaustion rejects attempts without evicting active quotas or retaining rejected clients.

Parameters
key:strUnique identifier for the rate-limited entity (e.g. IP, user id, route).
limit:intMaximum number of requests allowed within window.
window:intLength of the sliding window in seconds.
Returns
boolTrue when the request is within the limit, False when the quota is exceeded.
_GC_BATCH_SIZE: int = (source)

Gc batch size value used by MemoryRateLimitStore.

Value
64
_GC_INTERVAL: int = (source)

Inspect a bounded group of keys after each group of request attempts.

Value
16
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

Keys produced by deque.

Lock protecting concurrent access to shared state.

__max_events = (source)

Maximum number of accepted timestamps retained across all clients.

__max_keys = (source)

Maximum number of retained client buckets.

Entries retained by the in-memory storage backend.

Ticks value used by MemoryRateLimitStore.

__total_events: int = (source)

Total events value used by MemoryRateLimitStore.