Skip to content
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

Nameable Future-Proof hyper Executors #3097

Closed
seanmonstar opened this issue Dec 23, 2022 · 0 comments · Fixed by #3127
Closed

Nameable Future-Proof hyper Executors #3097

seanmonstar opened this issue Dec 23, 2022 · 0 comments · Fixed by #3127
Labels
A-rt Area: runtime traits/utils C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful.
Milestone

Comments

@seanmonstar
Copy link
Member

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:

  • 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.

But it has some annoying problems.

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.

@seanmonstar 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
@seanmonstar seanmonstar added this to the 1.0 RC2 milestone Dec 23, 2022
@seanmonstar seanmonstar moved this to Todo in hyper 1.0 Dec 23, 2022
@seanmonstar seanmonstar moved this from Todo to Blocked in hyper 1.0 Dec 23, 2022
@seanmonstar seanmonstar modified the milestones: 1.0 RC2, 1.0 RC3 Dec 29, 2022
@seanmonstar seanmonstar removed the B-rfc Blocked: More comments would be useful in determine next steps. label Dec 29, 2022
@seanmonstar seanmonstar moved this from Blocked to Todo in hyper 1.0 Dec 29, 2022
seanmonstar pushed a commit that referenced this issue Jan 31, 2023
…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 #2051
Closes #3097
@github-project-automation github-project-automation bot moved this from Todo to Done in hyper 1.0 Jan 31, 2023
0xE282B0 pushed a commit to 0xE282B0/hyper that referenced this issue Jan 12, 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.

Closes hyperium#2051
Closes hyperium#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.

Closes hyperium#2051
Closes hyperium#3097

Signed-off-by: Sven Pfennig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rt Area: runtime traits/utils C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant