Behaviour for Kathikon job workers.
Example
defmodule MyApp.EmailWorker do
use Kathikon.Worker
@impl true
def perform(%Kathikon.Job{args: %{"to" => email}}) do
MyApp.Mailer.deliver(email)
:ok
end
end
{:ok, _job} = Kathikon.insert(MyApp.EmailWorker, %{"to" => "user@example.com"})Return values
:ok— success; result stored perresult: :store | :discard{:ok, result}— success with explicit result{:error, reason}— failure; retry with backoff until max attempts, then dead-letter{:discard, reason}— permanent discard (no retry){:retry, reason}— failure treated as retryable even when attempts remain{:sleep, seconds}— defer without counting as failure
See docs/guides/workers.md.
Summary
Callbacks
@callback perform(job :: Kathikon.Job.t()) :: :ok | {:ok, term()} | {:error, term()} | {:discard, term()} | {:retry, term()} | {:sleep, pos_integer()}