We need to add possibility execute queries asynchronously i.e. not blocking HTTP request.
The design is pretty simple:
- Add
[POST] /async (or other name, naming is hard :)) method that receives similar payload to [POST] / with additional property .callback that represents a valid URL (we need to validate it before responding):
type AsyncScript struct {
Script
Callback string `json: "callback"`
}
- If everything is ok, the output must be an uuid value representing a job ID.
- Once Worker received an async payload, it schedules it internally using thread-pool.
- When Worker is done with a job, whether it failed or not, it should call a given callback url with a following payload
type AsyncResult struct {
Status string // succeeded or failed
Data byte[] // script result or error
}
We need to add possibility execute queries asynchronously i.e. not blocking HTTP request.
The design is pretty simple:
[POST] /async(or other name, naming is hard :)) method that receives similar payload to[POST] /with additional property.callbackthat represents a valid URL (we need to validate it before responding):