BullMQ.QueueEvents.Handler behaviour (BullMQ v1.3.2)
View SourceBehaviour for queue event handlers.
Implement this behaviour to create structured event handlers.
Example
defmodule MyApp.QueueHandler do
use BullMQ.QueueEvents.Handler
@impl true
def init(opts) do
{:ok, %{count: 0}}
end
@impl true
def handle_event(:completed, %{"jobId" => id}, state) do
Logger.info("Job completed: #{id}")
{:ok, %{state | count: state.count + 1}}
end
@impl true
def handle_event(_event, _data, state) do
{:ok, state}
end
end