Packages
honeydew
1.2.4
1.5.0
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.0
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc7
1.0.0-rc6
1.0.0-rc5
1.0.0-rc4
1.0.0-rc3
1.0.0-rc2
1.0.0-rc1
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Pluggable local/clusterable job queue focused on safety.
Current section
Files
Jump to
Current section
Files
README/workers.md
# Workers
Workers can be completely stateless, or initialized with state by implementing the `init/1` callback.
Worker state is immutable, the only way to change it is to cause the worker to crash and let Honeydew restart it.
Your worker module's `init/1` function must return `{:ok, state}`. If anything else is returned or your callback raises an error, the worker will execute your `failed_init/0` callback, if you've implemented it. If not, the worker will attempt to re-initialize in five seconds.
Check out the [initialized worker example](https://github.com/koudelka/honeydew/examples/initialized_worker).
If you'd like to re-initialize the worker from within your `failed_init/0` callback, you can do it like so:
```elixir
defmodule FailedInitWorker do
def init(_) do
raise "init failed"
end
def failed_init do
Honeydew.reinitialize_worker()
end
end
```