mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:56:02 -04:00
Clean up Notifier.on_new_room_event
code path (#8288)
The idea here is that we pass the `max_stream_id` to everything, and only use the stream ID of the particular event to figure out *when* the max stream position has caught up to the event and we can notify people about it. This is to maintain the distinction between the position of an item in the stream (i.e. event A has stream ID 513) and a token that can be used to partition the stream (i.e. give me all events after stream ID 352). This distinction becomes important when the tokens are more complicated than a single number, which they will be once we start tracking the position of multiple writers in the tokens. The valid operations here are: 1. Is a position before or after a token 2. Fetching all events between two tokens 3. Merging multiple tokens to get the "max", i.e. `C = max(A, B)` means that for all positions P where P is before A *or* before B, then P is before C. Future PR will change the token type to a dedicated type.
This commit is contained in:
parent
a3a90ee031
commit
5d3e306d9f
6 changed files with 44 additions and 37 deletions
|
@ -29,6 +29,7 @@ from synapse.replication.tcp.streams.events import (
|
|||
EventsStreamEventRow,
|
||||
EventsStreamRow,
|
||||
)
|
||||
from synapse.types import UserID
|
||||
from synapse.util.async_helpers import timeout_deferred
|
||||
from synapse.util.metrics import Measure
|
||||
|
||||
|
@ -98,7 +99,6 @@ class ReplicationDataHandler:
|
|||
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
self.store = hs.get_datastore()
|
||||
self.pusher_pool = hs.get_pusherpool()
|
||||
self.notifier = hs.get_notifier()
|
||||
self._reactor = hs.get_reactor()
|
||||
self._clock = hs.get_clock()
|
||||
|
@ -148,15 +148,12 @@ class ReplicationDataHandler:
|
|||
if event.rejected_reason:
|
||||
continue
|
||||
|
||||
extra_users = () # type: Tuple[str, ...]
|
||||
extra_users = () # type: Tuple[UserID, ...]
|
||||
if event.type == EventTypes.Member:
|
||||
extra_users = (event.state_key,)
|
||||
extra_users = (UserID.from_string(event.state_key),)
|
||||
max_token = self.store.get_room_max_stream_ordering()
|
||||
self.notifier.on_new_room_event(event, token, max_token, extra_users)
|
||||
|
||||
max_token = self.store.get_room_max_stream_ordering()
|
||||
await self.pusher_pool.on_new_notifications(max_token)
|
||||
|
||||
# Notify any waiting deferreds. The list is ordered by position so we
|
||||
# just iterate through the list until we reach a position that is
|
||||
# greater than the received row position.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue