pyrate_limiter.abstracts.store module¶
Storage for constant-state algorithms.
- class pyrate_limiter.abstracts.store.StateStore¶
Bases:
ABCHolds one key’s state for a
StateAlgorithm.The store’s only real job is atomicity:
check()must read the state, apply the transition and persist the result without another writer interleaving. How it achieves that is its own business - a lock in-process, a Lua script in Redis.- abstractmethod check(algorithm, rates, now, weight)¶
Apply
algorithm.stepto the stored state, atomically.
- close()¶
Release any resources held. Optional.
- Return type:
None
- default_clock = <pyrate_limiter.clocks.MonotonicClock object>¶
Used when the bucket is not given a clock. Shared stores override it, since a monotonic clock means nothing across machines.
- is_async = False¶
Nonemeans “ask the Leaker to probe” (a client that may be either).
- abstractmethod read(algorithm, rates)¶
Current state. For reporting only - never the basis of a decision.
- Return type:
Tuple[float,...] |Awaitable[Tuple[float,...]]
- abstractmethod reset()¶
Forget everything, as though the key had never been used.
- Return type:
None|Awaitable[None]