Using the supported nim packages such as asynchttpserver, is there anyway to get a Future of an http Request?
I need to mix separately servicing each http request into a complex algorithm. The program is using a browser as a GUI front end via AJAX like communication. In some cases a loop in the algorithm needs to periodically check if a particular request (determined by its query) from the browser is pending and if not, then continue that loop without interruption. In other cases, the algorithm needs to immediately wait for a second request. The infinite loop of server.serve(...) does not provide "peeking" at the request.
The code was originally done in go using channels and goroutines, but I noticed the channels package has a warning:
"Note: The current implementation of message passing is slow and does not work with cyclic data structures."
I am only sending strings over any channel, so that is not an issue. However "slow" performance may be a problem.
So a second question is whether the channel would have adequate performance when the browser is running on the same machine as the algorithm and is one of maybe three or four clients at most.
Thanks for any advice.
Hello geezer9,
is there anyway to get a Future of an http Request?
Currently no, but you could rather easily implement a nextRequest procedure in the asynchttpserver module. Then create a PR on the Nim repo to add it into the standard lib :)
Hello dom96
I am not ready to dip in the deep water yet - maybe in a few months.
Meanwhile, I wrote a very lightweight http handler based on the net module that exposes both the request accept and respond. It only needs to connect a browser with a local process.
Thanks