summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-05-13 15:51:50 +0100
committerErik Johnston <erik@matrix.org>2020-05-14 17:09:58 +0100
commit208ab7b13572ad8ad690ecc8bc044100def82431 (patch)
tree94fa5fe2f4f61bd752acd10f72bebaaaea97f73a
parentNewsfile (diff)
downloadsynapse-208ab7b13572ad8ad690ecc8bc044100def82431.tar.xz
Fix typing and add assertion.
-rw-r--r--synapse/storage/data_stores/main/push_rule.py3
-rw-r--r--synapse/storage/util/id_generators.py11
2 files changed, 13 insertions, 1 deletions
diff --git a/synapse/storage/data_stores/main/push_rule.py b/synapse/storage/data_stores/main/push_rule.py

index 121716288d..d1ad21a9f4 100644 --- a/synapse/storage/data_stores/main/push_rule.py +++ b/synapse/storage/data_stores/main/push_rule.py
@@ -16,6 +16,7 @@ import abc import logging +from typing import Union from canonicaljson import json @@ -82,7 +83,7 @@ class PushRulesWorkerStore( if hs.config.worker.worker_app is None: self._push_rules_stream_id_gen = ChainedIdGenerator( self._stream_id_gen, db_conn, "push_rules_stream", "stream_id" - ) + ) # type: Union[ChainedIdGenerator, SlavedIdTracker] else: self._push_rules_stream_id_gen = SlavedIdTracker( db_conn, "push_rules_stream", "stream_id" diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py
index 86d04ea9ac..f89ce0bed2 100644 --- a/synapse/storage/util/id_generators.py +++ b/synapse/storage/util/id_generators.py
@@ -166,6 +166,7 @@ class ChainedIdGenerator(object): def __init__(self, chained_generator, db_conn, table, column): self.chained_generator = chained_generator + self._table = table self._lock = threading.Lock() self._current_max = _load_current_id(db_conn, table, column) self._unfinished_ids = deque() # type: Deque[Tuple[int, int]] @@ -204,6 +205,16 @@ class ChainedIdGenerator(object): return self._current_max, self.chained_generator.get_current_token() + def advance(self, token: int): + """Stub implementation for advancing the token when receiving updates + over replication; raises an exception as this instance should be the + only source of updates. + """ + + raise Exception( + "Attempted to advance token on source for table %r", self._table + ) + class MultiWriterIdGenerator: """An ID generator that tracks a stream that can have multiple writers.