diff options
author | Erik Johnston <erik@matrix.org> | 2023-07-31 10:58:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 10:58:03 +0100 |
commit | ae55cc1e6bc6527d0e359a823c474f5c9ed4382e (patch) | |
tree | e874ad28d0ef94933201fe88511c9c8b93968a32 /synapse/notifier.py | |
parent | Bump types-commonmark from 0.9.2.3 to 0.9.2.4 (#16037) (diff) | |
download | synapse-ae55cc1e6bc6527d0e359a823c474f5c9ed4382e.tar.xz |
Add ability to wait for locks and add locks to purge history / room deletion (#15791)
c.f. #13476
Diffstat (limited to 'synapse/notifier.py')
-rw-r--r-- | synapse/notifier.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py index 897272ad5b..68115bca70 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -234,6 +234,9 @@ class Notifier: self._third_party_rules = hs.get_module_api_callbacks().third_party_event_rules + # List of callbacks to be notified when a lock is released + self._lock_released_callback: List[Callable[[str, str, str], None]] = [] + self.clock = hs.get_clock() self.appservice_handler = hs.get_application_service_handler() self._pusher_pool = hs.get_pusherpool() @@ -785,6 +788,19 @@ class Notifier: # that any in flight requests can be immediately retried. self._federation_client.wake_destination(server) + def add_lock_released_callback( + self, callback: Callable[[str, str, str], None] + ) -> None: + """Add a function to be called whenever we are notified about a released lock.""" + self._lock_released_callback.append(callback) + + def notify_lock_released( + self, instance_name: str, lock_name: str, lock_key: str + ) -> None: + """Notify the callbacks that a lock has been released.""" + for cb in self._lock_released_callback: + cb(instance_name, lock_name, lock_key) + @attr.s(auto_attribs=True) class ReplicationNotifier: |