-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement no op for room stream in sync #2022
Conversation
synapse/handlers/sync.py
Outdated
@@ -818,6 +831,38 @@ def handle_room_entries(room_entry): | |||
defer.returnValue((newly_joined_rooms, newly_joined_users)) | |||
|
|||
@defer.inlineCallbacks | |||
def _have_rooms_changed(self, sync_result_builder): | |||
"""Returns whether any rooms have changed since the sync. Must be an | |||
incremental sync |
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.
Would the doctring be clearer if it was written something like this?
"""Returns true if there are any new events in the rooms the user is in since the last sync
or if the user has changed membership in any room since the last sync.
This only makes sense when calculating an incremental sync."""
@@ -274,24 +274,25 @@ def _get_members_rows_txn(self, txn, room_id, membership=None, user_id=None): | |||
|
|||
return rows | |||
|
|||
@cached(max_entries=500000, iterable=True) | |||
@cachedInlineCallbacks(max_entries=500000, iterable=True) | |||
def get_rooms_for_user(self, user_id): |
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.
Would it make sense to have some docstring along the lines of:
"""Returns an immutable set of room_id strings for the rooms the user is joined to."""
@@ -765,6 +764,21 @@ def _generate_sync_entry_for_rooms(self, sync_result_builder, account_data_by_ro | |||
) | |||
sync_result_builder.now_token = now_token | |||
|
|||
# We check up front if anything has changed, if it hasn't then there is | |||
# no point in going futher. |
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.
Maybe comment on what expensive operations this avoids?
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.
It feels like that sort of comment would get out of date quickly, and wouldn't necessarily help that much.
Looks good codewise. I think the comments could be improved slightly but overall it looks pretty good. |
Updated comments. |
No description provided.