actix / actix/actix-web

Improve streaming interface

Abierto
#1,690 5 comentarios 10 reacciones 0 asignados Ver en GitHub
A-web C-improvement
Lenguaje dominante
Rust
Estrellas
24.8k
Forks
1.9k
Merge medio
23 h 10 min
PR fusionados (30 d)
26

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.