summary refs log tree commit diff
path: root/synapse/storage/util/sequence.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-08-25 17:32:30 +0100
committerGitHub <noreply@github.com>2020-08-25 17:32:30 +0100
commiteba98fb024af4c84901a7ba01940ffb3c50950c8 (patch)
treeca44f719eb5f877e047a6d0846ea0741b5e30ef1 /synapse/storage/util/sequence.py
parentDo not allow send_nonmember_event to be called with shadow-banned users. (#8158) (diff)
downloadsynapse-eba98fb024af4c84901a7ba01940ffb3c50950c8.tar.xz
Add functions to `MultiWriterIdGen` used by events stream (#8164)
Diffstat (limited to 'synapse/storage/util/sequence.py')
-rw-r--r--synapse/storage/util/sequence.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/storage/util/sequence.py b/synapse/storage/util/sequence.py

index 63dfea4220..ffc1894748 100644 --- a/synapse/storage/util/sequence.py +++ b/synapse/storage/util/sequence.py
@@ -14,7 +14,7 @@ # limitations under the License. import abc import threading -from typing import Callable, Optional +from typing import Callable, List, Optional from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine from synapse.storage.types import Cursor @@ -39,6 +39,12 @@ class PostgresSequenceGenerator(SequenceGenerator): txn.execute("SELECT nextval(?)", (self._sequence_name,)) return txn.fetchone()[0] + def get_next_mult_txn(self, txn: Cursor, n: int) -> List[int]: + txn.execute( + "SELECT nextval(?) FROM generate_series(1, ?)", (self._sequence_name, n) + ) + return [i for (i,) in txn] + GetFirstCallbackType = Callable[[Cursor], int]