So what I need is a way to let node calculate this huge thing I want it to calculate and immediately return 202 Accepted, and the status of the calculation is aksed via the Poller. Any ideas?
I have already such scenario in my Node/Express Endpoints:
module.export.poller = (req,res) ->
res.status(200).send({
percentFinished: precentFinished
})
module.export.beginHugeCalculation = (req,res) ->
async.waterfall [
(next) ->
# very, very, very, very time-intensive calculation here
next null
], (err) ->
# Success
return
# Immediately return HTTP 202 after Async Waterfall is triggered!
# Status can be requested via Poller Route
res.status(202).send({
inProgress : true
})
return
This works as expected with unit tests in the backend, the async is triggered, then a 202 is returned and via the Poller API I can ask about the progress (which is calculated somewhere else). Point is, as soon as I do this from the frontEnd in manual testing, the beginHugeCaluclation
is triggered and returns 202, and the poller requests I am sending each second are queued and return all at once only when async is finished, giving back 100% in every request.