Improve streaming interface
- Lingua principale
- Rust
- Stelle
- 24.8k
- Fork
- 1.9k
- Merge medio
- 23h 10m
- PR unite (30g)
- 26
Descrizione
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).
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.