I have got hyper http server. Processed requests issue async hyper requests to inner service, wait for async inner response, which is then mapped to the response for the original external request. Schematically it looks like external-request to inner-request to inner-response to external-response. I understand that constructed future chain is driven by hyper server as well as poll for incoming requests on the same single thread.
Now I would like to issue external-response without waiting for inner-response. I have attempted to change the logic but it seems Inner-response futures now require a separate driver for poll, like thread pool executor in scala.
I have tried to use futures_cpupool.spawn but got compiler error that hyper: client: request future is not send’able.
I have tried to use channel like mpsc from STD library or futures. Where inner request is issued by a consumer, and producers submit enough data to the channel from the external-request and respond with external-response immediately.
This seems better path forward but I have got the same problem: a thread should either poll for channel consumer events or drive inner request futures calling core.run() . Now I am thinking to do limited time poll for consumer and limited time poll for futures sequentially one after the other in the infinite loop on the same single thread, but it seems very low level solution. Is there better way? What is the right API to do limited time, interruptible poll for the channel consumer and futures result?