I’m developing a package which submits some jobs over the network. My main do_job(...)
function uses @async
and sends data over without blocking so I can submit multiple jobs and potentially handle them in parallel. However, having async API as a default might be overly complex. Often users will effectively wrap it with fetch(do_job(...))
.
I am new to the Julia community and it seems there should be an idiomatic way to have such an API. Here are the options I came up with:
- keyword parameter:
do_job(...; async=False) = async ? do_job(...) : fetch(do_job(...))
- two functions:
do_job(...)
anddo_job_async(...)
- Make
do_job
synchronous and let the user do@async(do_job(...))
if they need to do jobs in parallel. - …Any suggestions?