FaktoryWorker.Testing.perform_job
You're seeing just the macro
perform_job
, go back to FaktoryWorker.Testing module for more information.
Specs
Perform the job in the same way that it will be performed when pulled from the queue at runtime. Specifically, this means:
- work will be done in a separate process, under a
Task.Supervisor
- job arguments will go through serialization/deserialization
Blocks until the job has completed, returning the result of executing
the perform
function. If the job raises or exits, the return value
will be {:error, "raise or exit reason"}
. If the job times out
(execution time exceeds the job's :reserve_for
duration), {:error, :timeout}
will be returned instead of the normal result.
Note that ExUnit.CaptureLog
, ExUnit.CaptureIO
, and friends will
not work since the job process is not linked to the caller.
Examples
# arguments are optional for 0-arity jobs
perform_job(MyJob)
# single arguments may be passed directly
perform_job(MyJob, 123)
# multiple arguments in a list
perform_job(MyJob, ["foo", "bar"])
# you can pass options as well
perform_job(MyJob, ["arg1"], reserve_for: 1_500)
# if you need to pass options to a 0-arity job, you must
# pass an empty list for arguments
perform_job(MyJob, [], reserve_for: 1_500)