-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Opt-in to set Connection:Close on downstream requests #1441
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
base: develop
Are you sure you want to change the base?
Opt-in to set Connection:Close on downstream requests #1441
Conversation
Build failed, probably fixed by #1436 ? |
Conflicts: src/Ocelot/Requester/HttpClientBuilder.cs Cherry picked from ThreeMammals#1441
Please do the following:
|
d562ced
to
05d0c97
Compare
@bjartekh Hi Bjarte! I see that develop branch in your fork is too old. Is this PR related to an issue in backlog? |
05d0c97
to
b0b7f66
Compare
handlers | ||
.Select(handler => handler) | ||
.Reverse() | ||
.ToList() | ||
.ForEach(handler => | ||
{ | ||
var delegatingHandler = handler(); | ||
delegatingHandler.InnerHandler = httpMessageHandler; | ||
httpMessageHandler = delegatingHandler; | ||
}); | ||
return httpMessageHandler; | ||
} |
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.
handlers | |
.Select(handler => handler) | |
.Reverse() | |
.ToList() | |
.ForEach(handler => | |
{ | |
var delegatingHandler = handler(); | |
delegatingHandler.InnerHandler = httpMessageHandler; | |
httpMessageHandler = delegatingHandler; | |
}); | |
return httpMessageHandler; | |
} | |
return handlers | |
.Reverse() // Reverse the sequence | |
.Aggregate(httpMessageHandler, (currentHandler, handlerFunc) => | |
{ | |
var delegatingHandler = handlerFunc(); | |
delegatingHandler.InnerHandler = currentHandler; | |
return delegatingHandler; | |
}); | |
return httpMessageHandler; | |
} |
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.
Yeap! ToList
was a bit overhead to get access to ForEach
helper.
Aggregate
helper is good, for sure because it is applicable for this case.
There is another coding life hack: calling All
to process all elements of collection. 😃
But!... Ray, this file is redundant one! I left this file during rebasing just to keep the author's changes: see // TODO
😉
Both files are just container of new changes
- src/Ocelot/Requester/HttpClientBuilder.cs
- src/Ocelot/Requester/HttpClientWrapper.cs
You may check, there are no these files in develop! 🙃
This PR is not ready for reviews: it must be developed more ❗
b0b7f66
to
00469fc
Compare
c216cdf
to
b458f0f
Compare
908d84f
to
0678e7a
Compare
Fixes / New Feature #
ConnectionClose: true|false
underGlobalConfiguration
or perRoute
in the Ocelot configuration files.Proposed Changes
Side note: When benchmarking this on Azure Kubernetes Service (AKS), we observed that we got a higher throughput when running with Connnection:Close than using the
Ocelot.Provider.Kubernetes
package (which queries the Kubernetes API prior to sending each request). This is one scenario where this PR is beneficial.