WORKFLOW-199: polling every X seconds for job completion #138
+184
−109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the ability to pass new parameters to
POST /jobswhen creating a new job via the apiwait: set this totrueto have thePOSTrequest block while the job completescallback_urls: an optional array of endpoints to call, by the runner, when a job completes.A caller of the api service can create a job like this now
{ "workflow": "82280dc4-f5d9-4def-b5c1-a1361db9dd27", "wait": true, "callback_urls": [ "http://localhost:8080/jobdone" ] }where
waittells the API to return the headers immediately (containing the same headers thatPOST /jobswould normally give), but to wait until the job has completed to return the body. The body of the request will be the same body that would be supplied byGET /jobs/:uuid... ie. it will be a JSON body that gives the exit status of the job (completed, failed, etc.)callback_urlsshould contain a URL to hit the api service (the runner calls the urls incallback_urls) at the endpoint/jobdone, which is a new endpoint for the API service that takes aPOSTrequest with the output of a job, and uses that to end any requests that are currently waiting.todo
restify(if it makes sense)caveats
wait: truewithout registering the API service as acallback_urlwill result in the request hanging indefinitely