actix / actix/actix-web

Improve streaming interface

Offen
#1,690 5 Kommentare 10 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
A-web C-improvement
Vorherrschende Sprache
Rust
Sterne
24.8k
Forks
1.9k
Ø Merge
23 Std. 10 Min.
Gemergte PRs (30 T.)
26

Beschreibung

We use actix-web to handle some large file download, currently ResponseBuilder
can only provide streaming() interface which requires user to implment future::stream::Stream interface. (https://docs.rs/actix-web/3.0.2/actix_web/dev/struct.HttpResponseBuilder.html#method.streaming)
I think a trait simular to tokio::io::AsyncReader is prefered over Stream interface with morden async/await, base on the following reasons:

1) Reading over AsyncReader only pin a generated future on stack, while implenting a Stream usually requires using boxed future to poll other async fn, which is not effecient. And rust generator feature seams not going to be stable soon.

2) We discover is some cases Stream will be dropped once http client decided to stop reading it, when all the content-length has been read or early close due to error. the stream will not be poll until next() return None. there's no chance for a stream to cleanup it's resource in async way. (ie, notify remote storage to close the file connection).

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.