-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: main
Are you sure you want to change the base?
Conversation
- 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.
…n `ExpandableStringEnum`.
…s classes and interfaces in `implementation.serializer`.
…o the `implementation.util` package.
…s, Client Logger methods, sync suffix, API view comments
…it to `HttpRequestOptions`.
…unctionality and state tracking to `HttpPipelinePolicy`.
32be336
to
c117833
Compare
* | ||
* @return A response produced from sending the HTTP request. | ||
*/ | ||
public Response<?> process(HttpRequest httpRequest, HttpPipeline httpPipeline) { |
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.
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).
Removed
HttpPipelineNextPolicy
andHttpPipelineCallState
. RefactoredHttpPipelinePolicy
so it knows the next policy in the chain.