The Oban worker that delivers one signing code. A host uses it and names
it as the config's :code_worker; Countersign.Requests.request_code/2
then inserts the job in the transaction that wrote the code.
defmodule MyApp.Signing.CodeWorker do
use Countersign.Workers.Code, queue: :notifications, max_attempts: 3
@impl Countersign.Workers.Code
def config, do: MyApp.Signing.config()
endThe job's args are the code's id, the request's id and its scope, never the
code: the worker decrypts it from code_ciphertext when it runs
(Countersign.Requests.deliver_code/3). One job per code.
When the job runs:
- a code already used or past its 10 minutes, or a request the signer may no longer open, sends nothing and completes;
{:error, :retry}from the delivery retries, and on the last attempt gives up without failing the request: the signer can ask for a new code;- a permanent failure cancels the job, and has already failed a pending
request (
Countersign.Requests.fail/3).
Summary
Functions
A code job's args: the code, its request and the request's scope.
Runs a code job with config (what the generated perform/1 calls).
Callbacks
@callback config() :: Countersign.Config.t()
The config the worker delivers with.
Functions
@spec args(Countersign.Code.t(), Countersign.Request.t()) :: map()
A code job's args: the code, its request and the request's scope.
@spec perform(Countersign.Config.t(), Oban.Job.t()) :: :ok | {:error, :retry} | {:cancel, term()}
Runs a code job with config (what the generated perform/1 calls).