diff options
author | Erik Johnston <erik@matrix.org> | 2020-08-25 17:32:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 17:32:30 +0100 |
commit | eba98fb024af4c84901a7ba01940ffb3c50950c8 (patch) | |
tree | ca44f719eb5f877e047a6d0846ea0741b5e30ef1 /synapse/storage/util/sequence.py | |
parent | Do not allow send_nonmember_event to be called with shadow-banned users. (#8158) (diff) | |
download | synapse-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.py | 8 |
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] |