Tusk
Elixir task library with retry, success/failure callback and timeout
Built on top of supervisors
Installation
The package can be installed by adding tusk to your list of dependencies in mix.exs:
def deps do
[
{:tusk, "~> 0.1"}
]
endUsage
- Add Tusk.DynamicSupervisor to your supervision tree
Tusk.run(sup, task, options)-
where
supis the dynamic supervisor taskcan be an{m, f, a}tuple or a closure (anonymous function)
-
where
-
Available options
timeout:integer,:infinityornil-
both
:infinityandnildisable timeout
-
both
callbacks:on_success:mfa or closureon_failure:mfa or closureon_error:mfa or closure- on_success gets called with the task result
- on_failure is called once after no more retries
- on_error is called every time an error occurs
- on_failure and on_error get called with an error
no_retry_exceptions:- a list of Exception names that if seen, give up retrying