-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Replace reqwest with hyper + tower #394
Conversation
It should be possible with custom Service.
reqwest's timeout is applied from when the request starts connecting until the response body has finished. Use hyper-timeout to add timeout for reading the response.
use hyper::Body; | ||
|
||
/// Set cluster URL. | ||
pub fn set_cluster_url(req: Request<Body>, url: &url::Url) -> Request<Body> { |
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.
This can be used for a (hacky) solution for #209 by adding a placeholder in Api
then replacing it with default_ns
before making a request.
pub fn default_namespaced(client: Client) -> Self {
let resource = Resource::namespaced::<K>("{{default_ns}}");
Self {
resource,
client,
phantom: iter::empty(),
}
}
let inner = ServiceBuilder::new()
.map_request(move |r| finalize_url(r, &url, &default_ns))
.service(client);
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.
Hah, that is actually a pretty good solution. The braces would mean we cannot clash with an actual namespace.
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.
Looks really good, once again (original pr already had a significant amount of iteration). Everything is very cleanly done, modules delineated a lot better than before.
Less dependency multiplicity now that everything goes through the same service.
Have tested it a bit on your branch, and don't see any issues either, it just works. ✨
Happy to merge so we can rebase the remaining PRs (rather than the other way around).
Thanks for reviewing and testing. Glad to hear it just worked ✨ |
Awesome. It's going in! Thank you so much for digging into all of this (and effectively rewriting both the client and the config). This is a huge improvement.
|
Added some basic info about this in the CHANGELOG. Feel free to update as you see fit. Want me to wait with making a release until any of the follow-up tasks?
The last one would good for the sans-io story, even if it's only for us being able to provide a better testing. (Not sure there are any people masochistic enough to want to change out the full client stack, but maybe I am wrong). |
wow that was a lot of prs in one night, thanks a lot. |
All of it released in 0.49.0 ✨ |
based on suggestion in #394 (comment)
Replace
reqwest
withhyper
(#362) andtower
(#100). Supersedes #376.Changes
kube::Client
now useskube::Service
instead ofreqwest::Client
kube::Service
struct is atower::Service<http::Request<hyper::Body>>
. For convenience, a service based onhyper::Client
can be created fromkube::Config
, soClient::try_default()
is still supported. We can add a feature for this to provide an option for a sans-ioClient
(#204).To allow users to use their implementation when they need something not supported out of the box, I'm planning to change
Client::new(config: Config)
toClient::new(service: Service)
(creating aClient
fromConfig
is still possible withClient::new(config.try_into()?)
). This will also allow better testing.kube::Service
usestower::buffer::Buffer
, so it's cheap to clone (#17).Upgrade to WebSocket connection with
hyper
The above change was possible because of this. No more separate client for WebSocket! The connection is upgraded with
hyper
and aWebSocketStream
is created from the upgraded connection. All requests go throughkube::Service
.Other Improvements
Client::request_events
withtokio_util::codec::FramedRead
(Factor out chunked reader from Client::request_events #379)kube/src/service/tls.rs
.kube/src/config/auth.rs
hasHttpsConnector
for oauth requests andkube/src/config/mod.rs
has some hack for macOS, but that's about it.oauth2
(GCP OAuth) module with tame-oauth and made it optional (oauth
feature).config::auth
.AuthProvider
was not refreshing.AuthInfo
with provider other than GCP (Panic when creating Config object with Azure provider #238).Breaking Changes
oauth
is now opt-ingzip
should probably be opt-in for now because Kubernetes doesn't have it enabled by default yet and requires more dependencies. It's behindAPIResponseCompression
feature gate which is inBeta
since 1.16. See https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/.kube::Client::new(config: Config)
tokube::Client::new(service: Service)
Closes #100, #238, #362, #379