Skip to content

Create server util to allow pulling requests #2939

Open
@seanmonstar

Description

@seanmonstar

The current server API is callback-based, where Service is called whenever a request is received. Some applications need to invert it such that they take a request only when they are ready. This proposes creating a utility in hyper-util that would allow usage similar to this:

// naming is hard
let (svc, rx) = hyper_util::server::puller();

let conn = Http::new().serve_connection(socket, svc);
tokio::spawn(conn);

// pull off requests
while let Some((req, tx)) = rx.next().await? {
    println!("{:?}", req);
    tx.respond(Response::new(Empty::new());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-serverArea: server.C-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.K-hyper-utilCrate: hyper-util

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions