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

Enable direct cancellation for IHttpForwarder #1985

Merged
merged 4 commits into from
Jan 13, 2023
Merged

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Jan 4, 2023

Fixes #1542

Some customers using IHttpForwarder directly have asked for the ability to pass their own cancellation token. Today they have to replace HttpContext.RequestAborted which can be error prone.

This uses a Default Interface Method to avoid a breaking change.

@Tratcher Tratcher added this to the YARP 2.0.0 milestone Jan 4, 2023
@Tratcher Tratcher self-assigned this Jan 4, 2023
@Tratcher Tratcher enabled auto-merge (squash) January 4, 2023 21:51
@MihaZupan
Copy link
Member

While on the topic, should we augment ApplyAsync methods on transforms to accept CancellationTokens as well?

@Tratcher
Copy link
Member Author

Tratcher commented Jan 5, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Tratcher Tratcher disabled auto-merge January 5, 2023 20:20
@Tratcher
Copy link
Member Author

While on the topic, should we augment ApplyAsync methods on transforms to accept CancellationTokens as well?

Updated. How does that look @MihaZupan?

Copy link
Member

@MihaZupan MihaZupan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

We should also add CTs to the new extension methods we just added - https://github.com/microsoft/reverse-proxy/blob/main/src/ReverseProxy/Routing/DirectForwardingIEndpointRouteBuilderExtensions.cs. I can do that as a followup.

Nvm :)

@Tratcher
Copy link
Member Author

We should also add CTs to the new extension methods we just added - https://github.com/microsoft/reverse-proxy/blob/main/src/ReverseProxy/Routing/DirectForwardingIEndpointRouteBuilderExtensions.cs. I can do that as a followup.

? Those are route table wire-up methods, there's nothing to cancel. The one place we do call the forwarder would only ever be cancelled by the RequestAborted token.

@Tratcher Tratcher merged commit b5192aa into main Jan 13, 2023
@Tratcher Tratcher deleted the tratcher/forwardcancel branch January 13, 2023 04:00
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.

IHttpForwarder and cancellation
2 participants