Skip to content

Nameable Future-Proof hyper Executors #3097

@seanmonstar

Description

@seanmonstar

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.

Metadata

Metadata

Assignees

No one assigned

    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.

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions