Repository navigation
feat(http2): add an executor getter for server and client - #4250
robertream wants to merge 1 commit into
Conversation
720a9a0 to
8bae438
Compare
`Builder::new(exec)` is the only constructor on either HTTP/2 builder and the executor cannot be read back, so a caller that needs it for work alongside a connection keeps a second copy with nothing relating the two. `impl<E> Builder<E>` is unconstrained, so the accessor needs no bound, and returning `&E` leaves cloning to the caller.
8bae438 to
f10811e
Compare
cratelyn
left a comment
There was a problem hiding this comment.
hello, thank you for opening a pull request! my initial reaction is some skepticism that this new interface is truly needed.
the executor you'd want is the one already driving the connection, but there's no way to read it back off the builder, so you keep a second copy and hope they match.
i'm not sure what you mean by "second copy and hope they match". types like TokioExecutor can be freely cloned, since they are essentially an abstraction over functions like tokio::spawn etc.
is there a situation where not having access to the inner E can cause a bug or other incorrectness? is cloning the executor when constructing the server/client and passing it forward not possible?
|
For some broader context, I'm building an extension to hyper and axum to support WebTransport over HTTP/2, following the IETF standardization work, which is now in Working Group Last Call: https://datatracker.ietf.org/doc/draft-ietf-webtrans-http2/ I'm also building a gateway that terminates HTTP/3 WebTransport connections and proxies them to HTTP/2 WebTransport backends. The idea is that WebTransport servers can use HTTP/2 within a backend data center network without every service needing to implement HTTP/3 or QUIC. Apple shipped WebTransport in Safari 26.4 in March, on by default and including HTTP/2 fallback when QUIC isn't available, which as far as I know makes it the only shipping browser implementation of the HTTP/2 mapping. The draft itself is edited by Meta, with Apple, Mozilla, and Google co-authoring. The mapping of WebTransport onto HTTP/2 and hyper is fairly fussy, so I'd like to hide as much of that complexity as possible behind I'll be following up with a handful of PRs for the adjustments needed in As for the getter, you're right, there's no correctness issue. My "hope they match" wording implied one and shouldn't have. The executor is passed to The getter would extend that same affordance to extensions of the builder. hyper spares its own callers from supplying the executor at serve time, but an extension trait on It's one call site in one crate today. The difference is: // Today
Builder::new(TokioExecutor::new()).webtransport_service(config, router)
// Without the getter
let exec = TokioExecutor::new();
Builder::new(exec.clone()).webtransport_service(exec, config, router)If you'd rather not add the getter, that's completely fair. I'll just add the parameter to my own signature. |
Ran into this writing a WebTransport extension: a session has to be spawned once the response is out, and the executor you'd want is the one already driving the connection, but there's no way to read it back off the builder, so you keep a second copy and hope they match. Adds a getter on both builders.