You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
seanmonstar opened this issue
Dec 23, 2022
· 0 comments
· Fixed by #3127
Labels
A-rtArea: runtime traits/utilsC-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.
Make the Executor bounds on client and server types publicly nameable, while still preserving the ability to change internal spawning needs.
Background
hyper's client and server types require a hyper::rt::Executor to spawn some related background tasks.
There's two conflicting requirements for the executor:
The internal types that are spawned must be provided to the Executor (via Executor<InternalFuture>), so that the Sendiness can be propagated. This allows users to have !Send futures and bodies as long as they provide an Executor that can spawn them.
The internal types expose some of the private architecture, so being able to name them makes it impossible to refactor in the future. Being able to exhaustively name them would prevent us from spawning new background tasks as features are developed.
So far, we have solved this by using privately-public traits, which are blanketly implemented for all generic executors. This allows us to change the types internally, and as long as a user provides a type that is impl<F: Future> Executor<F> for MyExec, it just works.
The bounds are confusing in the documentation (for example).
Proposal
Define public trait aliases that are sealed, but can be named externally, and have documentation showing how to provide a Executor to match the bounds, and how to express the bounds in your own API.
For example: define hyper::rt::bounds::ServerConnHttp2Exec, which is a public trait.
This allows us to continue to not expose the actual internal types, and also to extend the trait to be represent spawning other tasks if need be.
The text was updated successfully, but these errors were encountered:
seanmonstar
added
C-feature
Category: feature. This is adding a new feature.
E-medium
Effort: medium. Some knowledge of how hyper internal works would be useful.
B-rfc
Blocked: More comments would be useful in determine next steps.
A-rt
Area: runtime traits/utils
labels
Dec 23, 2022
…unds` (#3127)
Define public trait aliases that are sealed, but can be named externally, and have documentation showing how to provide a Executor to match the bounds, and how to express the bounds in your own API.
Closes#2051Closes#3097
…unds` (hyperium#3127)
Define public trait aliases that are sealed, but can be named externally, and have documentation showing how to provide a Executor to match the bounds, and how to express the bounds in your own API.
Closeshyperium#2051Closeshyperium#3097
0xE282B0
pushed a commit
to 0xE282B0/hyper
that referenced
this issue
Jan 16, 2024
…unds` (hyperium#3127)
Define public trait aliases that are sealed, but can be named externally, and have documentation showing how to provide a Executor to match the bounds, and how to express the bounds in your own API.
Closeshyperium#2051Closeshyperium#3097
Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
A-rtArea: runtime traits/utilsC-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.
Goal
Make the
Executor
bounds on client and server types publicly nameable, while still preserving the ability to change internal spawning needs.Background
hyper's client and server types require a
hyper::rt::Executor
to spawn some related background tasks.There's two conflicting requirements for the executor:
Executor
(viaExecutor<InternalFuture>
), so that theSend
iness can be propagated. This allows users to have!Send
futures and bodies as long as they provide anExecutor
that can spawn them.So far, we have solved this by using privately-public traits, which are blanketly implemented for all generic executors. This allows us to change the types internally, and as long as a user provides a type that is
impl<F: Future> Executor<F> for MyExec
, it just works.But it has some annoying problems.
E: Executor<CantNameMe>
, norE: hyper::unnameable::ConnStreamExec
(see Don't use private traits in public APIs #2051; feat(server): add AutoConnection hyper-util#11 (comment)).Proposal
Define public trait aliases that are sealed, but can be named externally, and have documentation showing how to provide a
Executor
to match the bounds, and how to express the bounds in your own API.For example: define
hyper::rt::bounds::ServerConnHttp2Exec
, which is a public trait.This allows us to continue to not expose the actual internal types, and also to extend the trait to be represent spawning other tasks if need be.
The text was updated successfully, but these errors were encountered: