Function configuration

Copy Markdown View Source

Assign Inngest.FnOpts to @func to configure how a function is registered and scheduled. Public Elixir config uses snake_case atom keys. The SDK renders the spec's camelCase names only in the registration payload sent to Inngest.

defmodule MyApp.InvoiceWorkflow do
  use Inngest.Function

  @func %FnOpts{
    id: "invoice-workflow",
    name: "Invoice Workflow",
    retries: 5,
    debounce: %{
      key: "event.data.account_id",
      period: "10s",
      timeout: "1m"
    },
    priority: %{
      run: "event.data.priority"
    },
    throttle: %{
      key: "event.data.account_id",
      limit: 100,
      period: "1m",
      burst: 10
    },
    singleton: %{
      key: "event.data.invoice_id",
      mode: :skip
    },
    timeouts: %{
      start: "5m",
      finish: "1h"
    },
    concurrency: %{
      limit: 5,
      key: "event.data.account_id",
      scope: "fn"
    },
    idempotency: "event.data.invoice_id"
  }
  @trigger %Trigger{event: "invoice/created"}

  @impl true
  def exec(_ctx, _input), do: {:ok, "done"}
end

Supported options

OptionRequired fieldsOptional fieldsRegistration keyNotes
retriesnoneinteger retry countsteps.step.retries.attemptsDefaults to 3.
debounceperiodkey, timeoutdebounceperiod must be a duration up to 7 days.
prioritynonerunpriorityrun must be a CEL string when set.
batch_eventsmax_size, timeoutkeybatchEventsRenders max_size as maxSize; incompatible with rate_limit and cancel_on.
rate_limitlimit, periodkeyrateLimitperiod must be from 1 second to 60 seconds.
throttlelimit, periodkey, burstthrottleperiod must be a valid duration.
singletonmodekeysingletonmode must be :skip or :cancel; registration renders it as skip or cancel.
timeoutsnonestart, finishtimeoutsstart and finish must be valid durations when set.
idempotencyCEL expression stringnoneidempotencyPrevents duplicate events from triggering a function more than once in 24 hours.
concurrencylimit when using a mapkey, scopeconcurrencyMay also be a number or a list of maps. scope must be fn, env, or account.
cancel_oneventmatch, if, timeoutcancelMay be a map or a list of up to 5 maps.

Deferred fields

Checkpoint registration fields are intentionally not implemented. They should not be emitted until checkpointing runtime behavior is implemented.