mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:36:02 -04:00
Make StreamToken.room_key
be a RoomStreamToken
instance. (#8281)
This commit is contained in:
parent
c312ee3cde
commit
fe8ed1b46f
16 changed files with 114 additions and 99 deletions
|
@ -18,7 +18,7 @@
|
|||
import itertools
|
||||
import logging
|
||||
from collections import deque, namedtuple
|
||||
from typing import Iterable, List, Optional, Set, Tuple
|
||||
from typing import Dict, Iterable, List, Optional, Set, Tuple
|
||||
|
||||
from prometheus_client import Counter, Histogram
|
||||
|
||||
|
@ -31,7 +31,7 @@ from synapse.logging.context import PreserveLoggingContext, make_deferred_yielda
|
|||
from synapse.metrics.background_process_metrics import run_as_background_process
|
||||
from synapse.storage.databases import Databases
|
||||
from synapse.storage.databases.main.events import DeltaState
|
||||
from synapse.types import StateMap
|
||||
from synapse.types import Collection, StateMap
|
||||
from synapse.util.async_helpers import ObservableDeferred
|
||||
from synapse.util.metrics import Measure
|
||||
|
||||
|
@ -185,6 +185,8 @@ class EventsPersistenceStorage:
|
|||
# store for now.
|
||||
self.main_store = stores.main
|
||||
self.state_store = stores.state
|
||||
|
||||
assert stores.persist_events
|
||||
self.persist_events_store = stores.persist_events
|
||||
|
||||
self._clock = hs.get_clock()
|
||||
|
@ -208,7 +210,7 @@ class EventsPersistenceStorage:
|
|||
Returns:
|
||||
the stream ordering of the latest persisted event
|
||||
"""
|
||||
partitioned = {}
|
||||
partitioned = {} # type: Dict[str, List[Tuple[EventBase, EventContext]]]
|
||||
for event, ctx in events_and_contexts:
|
||||
partitioned.setdefault(event.room_id, []).append((event, ctx))
|
||||
|
||||
|
@ -305,7 +307,9 @@ class EventsPersistenceStorage:
|
|||
# Work out the new "current state" for each room.
|
||||
# We do this by working out what the new extremities are and then
|
||||
# calculating the state from that.
|
||||
events_by_room = {}
|
||||
events_by_room = (
|
||||
{}
|
||||
) # type: Dict[str, List[Tuple[EventBase, EventContext]]]
|
||||
for event, context in chunk:
|
||||
events_by_room.setdefault(event.room_id, []).append(
|
||||
(event, context)
|
||||
|
@ -436,7 +440,7 @@ class EventsPersistenceStorage:
|
|||
self,
|
||||
room_id: str,
|
||||
event_contexts: List[Tuple[EventBase, EventContext]],
|
||||
latest_event_ids: List[str],
|
||||
latest_event_ids: Collection[str],
|
||||
):
|
||||
"""Calculates the new forward extremities for a room given events to
|
||||
persist.
|
||||
|
@ -470,7 +474,7 @@ class EventsPersistenceStorage:
|
|||
# Remove any events which are prev_events of any existing events.
|
||||
existing_prevs = await self.persist_events_store._get_events_which_are_prevs(
|
||||
result
|
||||
)
|
||||
) # type: Collection[str]
|
||||
result.difference_update(existing_prevs)
|
||||
|
||||
# Finally handle the case where the new events have soft-failed prev
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue