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

Remove HttpPipelineNextPolicy #40084

Open
wants to merge 174 commits into
base: main
Choose a base branch
from

Conversation

vcolin7
Copy link
Member

@vcolin7 vcolin7 commented May 8, 2024

Removed HttpPipelineNextPolicy and HttpPipelineCallState. Refactored HttpPipelinePolicy so it knows the next policy in the chain.

samvaity and others added 30 commits October 11, 2023 16:46
- Moved some HTTP classes from `http` package to `http.models`.
- Renamed `HttpHeader` and `HttpHeaders` to `Header` and `HttpHeader`, respectively. Also moved them to the `models` package.
- Removed @deprecated methods.
- Removed "Sync" suffix from most classes and methods.
- Added necessary classes to `implementation` package.
…s classes and interfaces in `implementation.serializer`.
…s, Client Logger methods, sync suffix, API view comments
@vcolin7 vcolin7 added Client This issue points to a problem in the data-plane of the library. clientcore labels May 8, 2024
@vcolin7 vcolin7 requested review from lmolkova and g2vinay May 8, 2024 20:28
@vcolin7 vcolin7 self-assigned this May 8, 2024
@samvaity samvaity force-pushed the feature/generic-sdk-core-2 branch from 32be336 to c117833 Compare May 8, 2024 22:41
*
* @return A response produced from sending the HTTP request.
*/
public Response<?> process(HttpRequest httpRequest, HttpPipeline httpPipeline) {
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to be changing the API to remove HttpPipelineNextPolicy I think we should do a major break here instead of trying to retain a similar flow as azure-core. Right now, each pipeline has a mutable state with nextPolicy and HttpPipeline is supposed to be thread-safe which this will break. If two requests are being made where a common RetryPolicy is shared between two pipelines the nextPolicy may not point to the right following policy.

What I'll propose, split process into two methods, onRequest(HttpRequest) : HttpRequest and onResponse(HttpResponse) : HttpResponse. This makes HttpPipelinePolicy a stateless call and removes, what I believe wasn't a great pattern before, where the pipeline policy was both a mutator of requests and responses and managed a small bit of state management as it was forced to call HttpPipelineNextPolicy.process, and if it didn't now it broke the HttpPipeline call.

Simplifying HttpPipelinePolicy to onRequest and onResponse removes state management. It no longer needs to make a call to process the next policy, allowing the HttpPipelinePolicy to be a request and response mutator and HttpPipeline completely owns the state management. This would also allow for policies to be extended into more responsibilities in the future such as onException, if we find additional requirements (though I believe onRequest and onResponse would be sufficient for a long time).

Base automatically changed from feature/generic-sdk-core-2 to main May 13, 2024 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. clientcore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants