Extension points¶
paceapi has seven extension points. None requires subclassing: a key is a plain callable, and the rest are protocols checked structurally by your type checker.
| Extension point | Controls | Guide |
|---|---|---|
Store (LimiterStore, CacheStore) |
Where counters and cached values live | Custom stores |
Algorithm |
How a rate such as 5/minute is enforced |
Custom algorithms |
| Key function | Which caller a request is attributed to | Keys |
Serializer |
How cached values become bytes | Custom serializers |
Observer (LimiterObserver, CacheObserver) |
What happens with each decision, cache event, and failure | Observability |
HeaderStyle |
Which rate limit headers a response carries | Custom header styles |
Clock |
The current time | Testing |
Shared constraints¶
- Hot path: Keys,
Algorithm.step(), serializers, and observers run on the request path before the response is sent. Every request pays their cost. - Contract tests: The built-in stores and algorithms pass protocol-level test suites that you can run against your own implementation (see Custom stores and Custom algorithms). Both examples in this section had bugs that only those suites caught.