The Oban worker that renders and stores one signed request's certificate
(Countersign.Certificate). A host uses it and names it as the config's
:certificate_worker; Countersign.Requests.sign/3 then inserts the job in
the sign transaction.
defmodule MyApp.Signing.CertificateWorker do
use Countersign.Workers.Certificate,
queue: :exports,
max_attempts: 10,
time_zone: "America/Denver"
@impl Countersign.Workers.Certificate
def config, do: MyApp.Signing.config()
endThe job's args are the request's id and its scope; the request is loaded in that scope, so a job naming another scope finds nothing and cancels. One job per request (unique on the request id).
When the job runs:
- a request not found in the job's scope, or not signed, cancels;
- a request whose
certificate_refis set stores nothing and completes; - the certificate is rendered (
Countersign.Certificate.render/3) outside any transaction, then, with the request row lockedFOR UPDATE, checked for acertificate_refagain, stored throughCountersign.Signable.store_document/4and pinned; a rerun after a crash finds it pinned and stores nothing; {:error, :busy}or{:error, :timeout}from rendering or storing snoozes the job 30 seconds,{:cancel, reason}from storing cancels it, and any other error retries it.
Options
:queue- default:default.:max_attempts- default 10.:time_zone- passed toCountersign.Certificate(default UTC only).
Summary
Functions
A certificate job's args: the request and its scope.
Runs a certificate job (see the moduledoc).
Callbacks
@callback config() :: Countersign.Config.t()
The config the worker renders and stores with.
Functions
@spec args(Countersign.Request.t()) :: map()
A certificate job's args: the request and its scope.
@spec perform(Countersign.Config.t(), Oban.Job.t(), keyword()) :: :ok | {:snooze, pos_integer()} | {:cancel, term()} | {:error, term()}
Runs a certificate job (see the moduledoc).