Asynchronous process
When there is a lot of data to process, some services don’t return the results directly but start an asynchronous process (or thread). The thread writes results to a log which can be accessed at another time.
When a service starts a thread, it returns an HTTP code 202 Accepted instead of 200 OK.
XML returned
When a thread is started, the service output includes the following thread XML:
<thread id="[thread id]"
name="[thread name]"
username="[username of user starting thread]"
groupid="[ID of group if applicable or -1]"
status="[initialised|
inprogress|
error|
warning|
cancelled|
failed|
completed]">
[<message>[explanation or error]</message>]
[thread specific XML]
</thread>
For example:
<thread id="349f4fbcd872d514751f7809acf4d888"
name="Moving thread for group test-local5"
username="jjones"
groupid="240"
status="initialised">
<message>Finding URIs</message>
</thread>
The statuses error and warning are only transitory states – the thread always terminates only with one of completed, failed, or cancelled which are final states. This is because there might be several errors or warnings. Threads that include warnings usually result in a completed state and errors in a failed state.
Thread services
The API includes several services to work with threads.
| Server (Administrators) | Group (Contributors and higher) | |
|---|---|---|
| List threads | /threads | /groups/{group}/threads |
| View progress | /threads/{thread}/progress | /groups/{group}/threads/{thread}/progress |
| Get logs | /threads/{thread}/logs | /groups/{group}/threads/{thread}/logs |
| Cancel a thread | /threads/{thread}/cancel | /groups/{group}/threads/{thread}/cancel |
Services at the server level can only invoked by administrators.
Services at group level can be invoked by any member of the group with the role of contributor or manager.