This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow multiple workers to write to receipts stream. #16432
Merged
Merged
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c7d6f75
Add concrete MultiWriterStreamToken class
erikjohnston 7378d52
Use new class for receipts in `StreamToken`
erikjohnston f099895
Change function types
erikjohnston b012c88
Fix DB layer
erikjohnston 342d634
Fix appservice
erikjohnston e7acc24
Allow multiple receipt writers
erikjohnston bc37349
Newsfile
erikjohnston 0ae622f
Fix missing column on sqlite
erikjohnston f3462e6
Fix unit tests
erikjohnston 0484455
Fix replication
erikjohnston 98ae86a
Fix StreamToken.get_fields typing
erikjohnston 51c670d
Merge remote-tracking branch 'origin/develop' into erikj/multi_receipts2
erikjohnston 91218f9
Add tests
erikjohnston 68f57cd
Merge remote-tracking branch 'origin/develop' into erikj/multi_receipts2
erikjohnston a5d4d96
Updated schema delta version
erikjohnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow multiple workers to write to receipts stream. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,13 @@ | |
Dict, | ||
Iterable, | ||
List, | ||
Literal, | ||
Optional, | ||
Set, | ||
Tuple, | ||
TypeVar, | ||
Union, | ||
overload, | ||
) | ||
|
||
import attr | ||
|
@@ -44,6 +46,7 @@ | |
from synapse.streams.config import PaginationConfig | ||
from synapse.types import ( | ||
JsonDict, | ||
MultiWriterStreamToken, | ||
PersistedEventPosition, | ||
RoomStreamToken, | ||
StrCollection, | ||
|
@@ -127,7 +130,7 @@ def __init__( | |
def notify( | ||
self, | ||
stream_key: StreamKeyType, | ||
stream_id: Union[int, RoomStreamToken], | ||
stream_id: Union[int, RoomStreamToken, MultiWriterStreamToken], | ||
time_now_ms: int, | ||
) -> None: | ||
"""Notify any listeners for this user of a new event from an | ||
|
@@ -452,10 +455,48 @@ def _notify_pusher_pool(self, max_room_stream_token: RoomStreamToken) -> None: | |
except Exception: | ||
logger.exception("Error pusher pool of event") | ||
|
||
@overload | ||
def on_new_event( | ||
self, | ||
stream_key: Literal[StreamKeyType.ROOM], | ||
new_token: RoomStreamToken, | ||
users: Optional[Collection[Union[str, UserID]]] = None, | ||
rooms: Optional[StrCollection] = None, | ||
) -> None: | ||
... | ||
Comment on lines
+458
to
+466
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised we didn't already need this overload! Does it help avoid any asserts or anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't reduce assertions, as it only limits what is accepted as arguments (it doesn't change the return type). I added it to catch the case where we passed in an |
||
|
||
@overload | ||
def on_new_event( | ||
self, | ||
stream_key: Literal[StreamKeyType.RECEIPT], | ||
new_token: MultiWriterStreamToken, | ||
users: Optional[Collection[Union[str, UserID]]] = None, | ||
rooms: Optional[StrCollection] = None, | ||
) -> None: | ||
... | ||
|
||
@overload | ||
def on_new_event( | ||
self, | ||
stream_key: Literal[ | ||
StreamKeyType.ACCOUNT_DATA, | ||
StreamKeyType.DEVICE_LIST, | ||
StreamKeyType.PRESENCE, | ||
StreamKeyType.PUSH_RULES, | ||
StreamKeyType.TO_DEVICE, | ||
StreamKeyType.TYPING, | ||
StreamKeyType.UN_PARTIAL_STATED_ROOMS, | ||
], | ||
new_token: int, | ||
users: Optional[Collection[Union[str, UserID]]] = None, | ||
rooms: Optional[StrCollection] = None, | ||
) -> None: | ||
... | ||
|
||
def on_new_event( | ||
self, | ||
stream_key: StreamKeyType, | ||
new_token: Union[int, RoomStreamToken], | ||
new_token: Union[int, RoomStreamToken, MultiWriterStreamToken], | ||
users: Optional[Collection[Union[str, UserID]]] = None, | ||
rooms: Optional[StrCollection] = None, | ||
) -> None: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the documentation for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat inclined to leave this undocumented until we can test it? But I could also be persuaded otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. 👍