Question - async/await stream to many users using just 1 thread
vegarringdal opened this issue · 2 comments
Im very new to rust, so my question/sample code might be weird.
Im trying to build a small rest api with actix, where I stream large result sets back to client
But atm when I loop resultset with next it will pretty much block the thread for any new request ( I will only have 1 thread)
Since I use .fetch_array_size(100).prefetch_rows(100)
it would be useful if each request only worked with 100 rows then let other requests do little work etc. In this way I could stream back result to many clients, just a little slower..
Tried to wrap rows.next()
in async, but its still blocking. (at least I tried...
https://github.com/vegarringdal/rust/blob/try_async/apitest/src/main.rs#L26-L30
Is what Im trying to do possible ?
think I might have found a workaround, by adding a delay
updated the code