View Source Inngest.FnOpts (Inngest v0.2.1)

Function configuration options.

See the typespec for all available options.

Summary

Types

Configure how the function should consume batches of events (reference)

Define an event that can be used to cancel a running or sleeping function (reference)

Limit the number of concurrently running functions (reference)

Options to configure function debounce (reference).

A unique identifier for your function. This should not change between deploys.

A key expression which is used to prevent duplicate events from triggering a function more than once in 24 hours.

A name for your function. If defined, this will be shown in the UI as a friendly display name instead of the ID.

Prioritize specific function runs ahead of others (reference)

Options to configure how to rate limit function execution (reference)

Configure the number of times the function will be retried from 0 to 20. Default: 3

t()

Types

@type batch_events() :: %{max_size: number(), timeout: binary()} | nil

Configure how the function should consume batches of events (reference)

max_size - number required

The maximum number of events a batch can have. Current limit is 100.

timeout - string required

How long to wait before invoking the function with the batch even if it's not full. Current permitted values are from 1s to 60s.

@type cancel_on() :: cancel_option() | [cancel_option()] | nil

Define an event that can be used to cancel a running or sleeping function (reference)

event - string required

The event name which will be used to cancel

match - string optional

The property to match the event trigger and the cancelling event, using dot-notation e.g. data.userId

if - string optional

TODO

timeout - string optional

The amount of time to wait to receive the cancelling event. e.g. 30m, 3h, or 2d

@type cancel_option() :: %{
  event: binary(),
  match: binary() | nil,
  if: binary() | nil,
  timeout: binary() | nil
}
@type concurrency() :: number() | concurrency_option() | [concurrency_option()] | nil

Limit the number of concurrently running functions (reference)

limit - string required

The maximum number of concurrently running steps.

key - string optional

A unique key expression for which to restrict concurrently running steps to. The expression is evaluated for each triggering event and a unique key is generate.

@type concurrency_option() ::
  %{limit: number(), key: binary() | nil, scope: binary() | nil} | nil
@type debounce() :: %{key: binary() | nil, period: binary()} | nil

Options to configure function debounce (reference).

period - string required

The time period of which to set the limit. The period begins when the first matching event is received. How long to wait before invoking the function with the batch even if it's not full. Current permitted values are from 1s to 7d (168h).

key - string optional

A unique key expression to apply the debounce to. The expression is evaluated for each triggering event.

Expressions are defined using the Common Expression Language (CEL) with the original event accessible using dot-notation. Examples:

  • Debounce per customer id: event.data.customer_id
  • Debounce per account and email address: event.data.account_id + "-" + event.user.email
@type id() :: binary()

A unique identifier for your function. This should not change between deploys.

@type idempotency() :: binary() | nil

A key expression which is used to prevent duplicate events from triggering a function more than once in 24 hours.

This is equivalent to setting rate_limit with a key, a limit of 1 and period of 24hr.

Expressions are defined using the Common Expression Language (CEL) with the original event accessible using dot-notation. Examples:

  • Only run once for each customer id: event.data.customer_id
  • Only run once for each account and email address: event.data.account_id + "-" + event.user.email
@type name() :: binary() | nil

A name for your function. If defined, this will be shown in the UI as a friendly display name instead of the ID.

@type priority() :: %{run: binary() | nil} | nil

Prioritize specific function runs ahead of others (reference)

run - string optional

An expression which must return an integer between -600 and 600 (by default), with higher return values resulting in a higher priority. See reference for more information.

@type rate_limit() :: %{limit: number(), period: binary(), key: binary() | nil} | nil

Options to configure how to rate limit function execution (reference)

limit - number required

The maximum number of functions to run in the given time period.

period - number required

The time period of which to set the limit. The period begins when the first matching event is received. How long to wait before invoking the function with the batch even if it's not full. Current permitted values are from 1s to 60s.

key - string optional

A unique key expression to apply the limit to. The expression is evaluated for each triggering event.

Expressions are defined using the Common Expression Language (CEL) with the original event accessible using dot-notation. Examples:

  • Rate limit per customer id: event.data.customer_id
  • Rate limit per account and email address: event.data.account_id + "-" + event.user.email

Note

This option cannot be used with cancel_on and rate_limit.

@type retries() :: number() | nil

Configure the number of times the function will be retried from 0 to 20. Default: 3

@type t() :: %Inngest.FnOpts{
  batch_events: batch_events(),
  cancel_on: cancel_on(),
  concurrency: concurrency(),
  debounce: debounce(),
  id: id(),
  idempotency: idempotency(),
  name: name(),
  priority: priority(),
  rate_limit: rate_limit(),
  retries: retries()
}