summary refs log tree commit diff
path: root/synapse/module_api/callbacks/ratelimit_callbacks.py
diff options
context:
space:
mode:
authorHugh Nimmo-Smith <hughns@users.noreply.github.com>2025-06-06 11:48:49 +0100
committerGitHub <noreply@github.com>2025-06-06 10:48:49 +0000
commit82189cbde45225d6c8793018343f265894ac8e23 (patch)
treef2b7bdf0b126b1717cd524ee35975c3b9a8db5a9 /synapse/module_api/callbacks/ratelimit_callbacks.py
parentDistinguish all vs local events being persisted in the "Event Send Time Quant... (diff)
downloadsynapse-82189cbde45225d6c8793018343f265894ac8e23.tar.xz
Export RatelimitOverride from ModuleApi (#18513)
Diffstat (limited to 'synapse/module_api/callbacks/ratelimit_callbacks.py')
-rw-r--r--synapse/module_api/callbacks/ratelimit_callbacks.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/module_api/callbacks/ratelimit_callbacks.py b/synapse/module_api/callbacks/ratelimit_callbacks.py

index ced721b407..64f9cc81e8 100644 --- a/synapse/module_api/callbacks/ratelimit_callbacks.py +++ b/synapse/module_api/callbacks/ratelimit_callbacks.py
@@ -15,7 +15,8 @@ import logging from typing import TYPE_CHECKING, Awaitable, Callable, List, Optional -from synapse.storage.databases.main.room import RatelimitOverride +import attr + from synapse.util.async_helpers import delay_cancellation from synapse.util.metrics import Measure @@ -24,6 +25,17 @@ if TYPE_CHECKING: logger = logging.getLogger(__name__) + +@attr.s(auto_attribs=True) +class RatelimitOverride: + """Represents a ratelimit being overridden.""" + + per_second: float + """The number of actions that can be performed in a second. `0.0` means that ratelimiting is disabled.""" + burst_count: int + """How many actions that can be performed before being limited.""" + + GET_RATELIMIT_OVERRIDE_FOR_USER_CALLBACK = Callable[ [str, str], Awaitable[Optional[RatelimitOverride]] ]