mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-16 00:23:50 -05:00
Add EventStreamPosition type (#8388)
The idea is to remove some of the places we pass around `int`, where it can represent one of two things: 1. the position of an event in the stream; or 2. a token that partitions the stream, used as part of the stream tokens. The valid operations are then: 1. did a position happen before or after a token; 2. get all events that happened before or after a token; and 3. get all events between two tokens. (Note that we don't want to allow other operations as we want to change the tokens to be vector clocks rather than simple ints)
This commit is contained in:
parent
13099ae431
commit
ac11fcbbb8
11 changed files with 100 additions and 57 deletions
|
|
@ -20,6 +20,7 @@ from synapse.events import FrozenEvent, _EventInternalMetadata, make_event_from_
|
|||
from synapse.handlers.room import RoomEventSource
|
||||
from synapse.replication.slave.storage.events import SlavedEventStore
|
||||
from synapse.storage.roommember import RoomsForUser
|
||||
from synapse.types import PersistedEventPosition
|
||||
|
||||
from tests.server import FakeTransport
|
||||
|
||||
|
|
@ -204,10 +205,14 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
|
|||
type="m.room.member", sender=USER_ID_2, key=USER_ID_2, membership="join"
|
||||
)
|
||||
self.replicate()
|
||||
|
||||
expected_pos = PersistedEventPosition(
|
||||
"master", j2.internal_metadata.stream_ordering
|
||||
)
|
||||
self.check(
|
||||
"get_rooms_for_user_with_stream_ordering",
|
||||
(USER_ID_2,),
|
||||
{(ROOM_ID, j2.internal_metadata.stream_ordering)},
|
||||
{(ROOM_ID, expected_pos)},
|
||||
)
|
||||
|
||||
def test_get_rooms_for_user_with_stream_ordering_with_multi_event_persist(self):
|
||||
|
|
@ -293,9 +298,10 @@ class SlavedEventStoreTestCase(BaseSlavedStoreTestCase):
|
|||
# the membership change is only any use to us if the room is in the
|
||||
# joined_rooms list.
|
||||
if membership_changes:
|
||||
self.assertEqual(
|
||||
joined_rooms, {(ROOM_ID, j2.internal_metadata.stream_ordering)}
|
||||
expected_pos = PersistedEventPosition(
|
||||
"master", j2.internal_metadata.stream_ordering
|
||||
)
|
||||
self.assertEqual(joined_rooms, {(ROOM_ID, expected_pos)})
|
||||
|
||||
event_id = 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue