Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcserver: Pass request context to handlers. #3026

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Nov 27, 2022

This requires #3025.

Currently, the handler for the HTTP endpoint passes the server context to the handlers which ensures that they can cancel immediately in the event of server shutdown. Meanwhile, the WebSocket endpoint relies on the server disconnecting the clients when it is shutdown in order to signal cancellation. In both cases, however, the context is not cancelled when a client initiates the disconnect which means handlers do not have the opportunity to cancel early in that case.

In order to make it so that the handlers can cancel early in all of the aforementioned scenarios, this modifies the handlers for both the HTTP and WebSocket endpoints to make use of the request context instead of the server context and arranges for each request context to use the server context as their parent context.

It also modifies all of the individual websocket-specific handlers to accept the context in the same way the shared handlers for both endpoints do so they are able to make use of early cancellation if desired as well.

@davecgh davecgh added this to the 1.8.0 milestone Nov 27, 2022
@davecgh davecgh force-pushed the rpcserver_pass_req_contexts branch from 8d86f87 to 9fd612c Compare November 27, 2022 05:51
Currently, the handler for the HTTP endpoint passes the server context
to the handlers which ensures that they can cancel immediately in the
event of server shutdown.  Meanwhile, the WebSocket endpoint relies on
the server disconnecting the clients when it is shutdown in order to
signal cancellation.  In both cases, however, the context is not
cancelled when a client initiates the disconnect which means handlers
do not have the opportunity to cancel early in that case.

In order to make it so that the handlers can cancel early in all of the
aforementioned scenarios, this modifies the handlers for both the HTTP
and WebSocket endpoints to make use of the request context instead of
the server context and arranges for each request context to use the
server context as their parent context.

It also modifies all of the individual websocket-specific handlers to
accept the context in the same way the shared handlers for both
endpoints do so they are able to make use of early cancellation if
desired as well.
@davecgh davecgh force-pushed the rpcserver_pass_req_contexts branch from 9fd612c to 5eda2a2 Compare November 28, 2022 21:19
@davecgh davecgh merged commit 5eda2a2 into decred:master Nov 28, 2022
@davecgh davecgh deleted the rpcserver_pass_req_contexts branch November 28, 2022 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants