Asynchronous mechanism
Generation
The asynchronous mechanism is very simple. Think of a synchronous function, but instead of getting the current response immediatly you get an id, that allows retrieving current progress of the action. Once the action is completed, you call the (same_function_name)_result function and you will get the response, or an exception asif you where calling the synchronous way.
Let's take the example of run_smart_test function.
function run_smart_test:
async: true
in: - Integer slot_id
out: - Boolean device_ok
errors: void
this will turn into two functions (example in python)
def run_smart_test(self, client_ref, slot_id):
#Do some stuff
return job_id
def run_smart_test_result(self, job_id):
#does some stuff
return device_ok
You can notice that a client_ref parameter has appeard in the run_smart_test method. This parameter is just an identifier that the client can fill as he wants, in order to be able to make the distinction between various jobs. This parameter is not modified by the server.
Once a job is running, its current status can be accessed thanks to the get_job_status or the list_jobs method
def get_job_status(self, job_id):
#Do stuff
return JobStatus()
def get_jobs_list(self, listInfo):
#Do stuff
return ResultSet(JobsStatus)
Service and Objects definitions
AsyncJobStatus
enum AsyncJobStatus(Integer){
UNKNOWN = -1,
INIT = 1,
RUNNING = 2,
PAUSED = 3,
COMPLETED = 4,
FAILED = 5,
}
AsyncJob
typedef AsyncJob(){
id: Integer[RO],
progress: Integer[RO],
#progress: -1 means no progress for this job
status: Integer[RO],
client_ref: Integer[RO],
#client_ref: referenc given by the client at the creation of the job
}
get_job_status
function get_jobs_list:
in: - ListInfo list_info
out: - AsyncJob async_jobs
errors: void
search_criteria: - Unicode name_starts_with
- AsyncJobStatus status
get_jobs_list
function get_jobs_list:
in: - ListInfo list_info
out: - ResultSet async_jobs
errors: void
search_criteria: - Unicode name_starts_with
- AsyncJobStatus status