https://github.com/princemaple/tusk
Elixir task library with retry, success/failure callback and timeout
https://github.com/princemaple/tusk
callback elixir retry supervisor task timeout
Last synced: 5 months ago
JSON representation
Elixir task library with retry, success/failure callback and timeout
- Host: GitHub
- URL: https://github.com/princemaple/tusk
- Owner: princemaple
- License: mit
- Created: 2018-06-13T10:58:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-05T06:44:24.000Z (about 3 years ago)
- Last Synced: 2025-10-11T03:27:46.183Z (8 months ago)
- Topics: callback, elixir, retry, supervisor, task, timeout
- Language: Elixir
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`:
```elixir
def deps do
[
{:tusk, "~> 0.1"}
]
end
```
## Usage
- Add Tusk.DynamicSupervisor to your supervision tree
- `Tusk.run(sup, task, options)`
- where `sup` is the dynamic supervisor
- `task` can be an `{m, f, a}` tuple or a closure (anonymous function)
- Available options
- `timeout:` integer, `:infinity` or `nil`
- both `:infinity` and `nil` disable timeout
- `callbacks:`
- `on_success:` mfa or closure
- `on_failure:` mfa or closure
- `on_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