View Source OddJob.Job (OddJob v0.5.1)
The OddJob.Job struct holds all of the useful information about a job.
Link to this section Summary
Types
The OddJob.Job struct is the datatype that is passed between processes charged with performing
the job.
Link to this section Types
Specs
t() :: %OddJob.Job{
async: boolean(),
function: function() | nil,
owner: pid() | nil,
proxy: pid() | nil,
ref: reference() | nil,
results: term() | nil
}
The OddJob.Job struct is the datatype that is passed between processes charged with performing
the job.
It holds all of the data that is necessary to link, monitor, perform work, and return results to the caller.
The job struct is only returned to the caller when using the async/await pattern. When the caller receives
the struct after calling OddJob.async_perform/2 the :results field is always nil, even though the
work could conceivably already be done. This is because the results are not waited on at the time the
struct is created. The results are only known when passing the job to OddJob.await/2 or matching on the
{ref, results} message.
:functionis the anonymous function that will be performed by the worker:resultsis the term that is returned byfunction. This is only used internally by the processes performing the work.:asyncis an boolean identifying if the job's results can be awaited on:refis the unique monitor reference of the job:owneris the pid of the calling process, i.e.self():proxyis thepidof the proxy server that creates the job and routes the results. Theownerlinks and monitors theproxy, while theproxylinks and monitors the worker. Exit messages and failures cascade up to theowner. The worker sends results back to theproxy, which then sends them to theownerbefore exiting with reason:normal.