Timer to schedule jobs in small intervals.
The package can be installed as:
- Add
ticker
to your list of dependencies inmix.exs
:
```elixir
def deps do
[{:ticker, "~> 0.0.1"}]
end
```
- Ensure
ticker
is started before your application:
```elixir
def application do
[applications: [:ticker]]
end
```
- Add ticker to your supervised worker list
Module is the module you want to call.
Function is the function on the module you want to call.
Interval is the interval in milliseconds that you want this function repeatedly called.
This example is every 30 seconds.
```elixir
children = [
worker(Ticker, [%{module: SomeWorker, function: :work, interval: 30_000}])
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
```