To my knowledge, there is no task model in OpenCPU, i.e. one has to wait arbitrarily long with an open TCP connection until the request finishes.
One possibility for a task model implementation would be to return a dedicated task uri with status 200 OK
immediately for a POST
request when one wishes to running a function. The advantage would be that the client would get a result immediately while the job runs on the server in the background.
The client would then poll the task URI until it returns 201 created
, meaning the job has successfully finished, or an error code for unsuccessful calls. In the success case, the body would contain the same resource list that is created directly by POST
now.
What is the opinion on this model or a similar approach? How does everyone handle this? I think support for long running jobs without open TCP connection would be valuable. Optional features such as supplying progress information while polling the still running job etc. also comes to my mind.