Closed kylegentle closed 2 years ago
Thanks for bringing this up! I didn't look into the details yet, but if you think this can be solved by following hypers own conventions, the google crates should certainly follow suit.
PRs are welcome. In case you want to take it on, please only submit changes to src/
without regenerating the APIs. Thank you.
Thanks for the quick response, @Byron!
I'm pretty new to Rust, and totally new to Mako, but I'll share what I've got so far. From there, if you can provide some guidance I'd be happy to write a fix, or if you decide it would be more efficient to do it yourself, of course that's great too.
The approach I have in mind is to update Hub's client
type to:
hyper::Client<tower_service::Service<http::Uri>, hyper::body::Body>
This is more or less what hyper does with the connector
parameter of their client builder (code pointer).
Link to the tower_service::Service
trait for reference.
So my thinking is that we:
tower_service
as a dependency in Cargo.toml.use tower_service::Service
and use http:Uri
to src/rust/api/client.rs.new
function.
b. Update the hub type parameters.3b is the part I feel least equipped to tackle at this point, but I'd love a sanity check on the rest too. I'm sure I don't have a complete picture yet. :smile:
Edit: tower::Service --> tower_service::Service, since that's how hyper_rustls does it.
Thanks a lot for the summary!
It looks like tower_service
adds the much needed abstraction layer to not bind so closely to the underlying transport, which sounds like the right approach.
Maybe there should also be a point 4) which updates the CLI code as it will instantiate an API hub as well.
As to how to proceed from here, maybe it helps to share my typical workflow. Usually I use the groups_migration
codebase to try things. You could prototype the changes there and fiddle with the types until it works. The same could be done for the CLI of groups_migration
for completeness. Once this works, these changes 'just' have to be transferred to the mako
source, which usually is quite mechanical. make
can be used to repeatedly make groupsmigration1-cargo ARGS=check
for validation, along with make groupsmigration1-cli-cargo ARGS=check
for the cli related code.
I hope that helps.
I discovered that this is also an issue in yup-oauth2; submitted a PR to fix it there as well.
As written, Hubs require clients to use a
hyper_rustls::HttpsConnector
:https://github.com/Byron/google-apis-rs/blob/93de38dddd36ab21eb99f782a3a6dbdc4173220f/src/mako/api/api.rs.mako#L52
Unfortunately, this connector doesn't support HTTP proxies (see related issue).
Can we make Hub::new() more generic, to enable customized connectors like those of
hyper_proxy
? This would also follow the convention of hyper's own builder.