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
Enable cancellation of GET /members
and GET /state
requests
#12708
Merged
squahtx
merged 6 commits into
develop
from
squah/enable_room_members_and_state_cancellation
May 11, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8465334
Allow `@cancellable` to be used on methods whose names have suffixes
1b90a82
Enable cancellation of `GET /rooms/<room_id>/members` requests
5b301d8
Enable cancellation of `GET /rooms/<room_id>/state` requests
7acab57
Enable cancellation of `GET /rooms/<room_id>/state/<event_type>/*` re…
05e6b68
Add newsfile
f24217d
Improve variable name (thanks dmr!)
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 @@ | ||
Enable cancellation of `GET /rooms/$room_id/members`, `GET /rooms/$room_id/state` and `GET /rooms/$room_id/state/$event_type/*` requests. |
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 |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
) | ||
from synapse.api.filtering import Filter | ||
from synapse.events.utils import format_event_for_client_v2 | ||
from synapse.http.server import HttpServer | ||
from synapse.http.server import HttpServer, cancellable | ||
from synapse.http.servlet import ( | ||
ResolveRoomIdMixin, | ||
RestServlet, | ||
|
@@ -143,6 +143,7 @@ def register(self, http_server: HttpServer) -> None: | |
self.__class__.__name__, | ||
) | ||
|
||
@cancellable | ||
def on_GET_no_state_key( | ||
self, request: SynapseRequest, room_id: str, event_type: str | ||
) -> Awaitable[Tuple[int, JsonDict]]: | ||
|
@@ -153,6 +154,7 @@ def on_PUT_no_state_key( | |
) -> Awaitable[Tuple[int, JsonDict]]: | ||
return self.on_PUT(request, room_id, event_type, "") | ||
|
||
@cancellable | ||
async def on_GET( | ||
self, request: SynapseRequest, room_id: str, event_type: str, state_key: str | ||
) -> Tuple[int, JsonDict]: | ||
|
@@ -481,6 +483,7 @@ def __init__(self, hs: "HomeServer"): | |
self.auth = hs.get_auth() | ||
self.store = hs.get_datastores().main | ||
|
||
@cancellable | ||
async def on_GET( | ||
self, request: SynapseRequest, room_id: str | ||
) -> Tuple[int, JsonDict]: | ||
|
@@ -602,6 +605,7 @@ def __init__(self, hs: "HomeServer"): | |
self.message_handler = hs.get_message_handler() | ||
self.auth = hs.get_auth() | ||
|
||
@cancellable | ||
async def on_GET( | ||
Comment on lines
+608
to
609
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. Similarly---is it easy to summarise why this is safe? I suppose the fact that we're doing a GET suggests that we'll only be reading data, not writing it... which sounds generally safer to cancel.(?) |
||
self, request: SynapseRequest, room_id: str | ||
) -> Tuple[int, List[JsonDict]]: | ||
|
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.
Sanity check: why is this request cancellation-safe? (I assume it follows from all your other PRs?)