Skip to content

Commit

Permalink
move nil to each type instead
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin67 committed Nov 27, 2023
1 parent e16544b commit cd4916e
Showing 1 changed file with 49 additions and 39 deletions.
88 changes: 49 additions & 39 deletions lib/inngest/function/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ defmodule Inngest.FnOpts do

@type t() :: %__MODULE__{
id: id(),
name: name() | nil,
retries: retries() | nil,
debounce: debounce() | nil,
priority: priority() | nil,
batch_events: batch_events() | nil,
rate_limit: rate_limit() | nil,
idempotency: idempotency() | nil,
concurrency: concurrency() | nil,
cancel_on: cancel_on() | nil
name: name(),
retries: retries(),
debounce: debounce(),
priority: priority(),
batch_events: batch_events(),
rate_limit: rate_limit(),
idempotency: idempotency(),
concurrency: concurrency(),
cancel_on: cancel_on()
}

@typedoc """
Expand All @@ -39,12 +39,12 @@ defmodule Inngest.FnOpts do
@typedoc """
A name for your function. If defined, this will be shown in the UI as a friendly display name instead of the ID.
"""
@type name() :: binary()
@type name() :: binary() | nil

@typedoc """
Configure the number of times the function will be retried from `0` to `20`. Default: `3`
"""
@type retries() :: number()
@type retries() :: number() | nil

@typedoc """
Options to configure function debounce ([reference](https://www.inngest.com/docs/reference/functions/debounce)).
Expand All @@ -62,10 +62,12 @@ defmodule Inngest.FnOpts do
* Debounce per customer id: `event.data.customer_id`
* Debounce per account and email address: `event.data.account_id + "-" + event.user.email`
"""
@type debounce() :: %{
key: binary() | nil,
period: binary()
}
@type debounce() ::
%{
key: binary() | nil,
period: binary()
}
| nil

@typedoc """
Prioritize specific function runs ahead of others ([reference](https://www.inngest.com/docs/reference/functions/run-priority))
Expand All @@ -75,9 +77,11 @@ defmodule Inngest.FnOpts do
An expression which must return an integer between -600 and 600 (by default), with higher return values resulting in a higher priority.
See [reference](https://www.inngest.com/docs/reference/functions/run-priority) for more information.
"""
@type priority() :: %{
run: binary() | nil
}
@type priority() ::
%{
run: binary() | nil
}
| nil

@typedoc """
Configure how the function should consume batches of events ([reference](https://www.inngest.com/docs/guides/batching))
Expand All @@ -90,29 +94,35 @@ defmodule Inngest.FnOpts do
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 batch_events() :: %{
max_size: number(),
timeout: binary()
}

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

@type idempotency() :: binary()

@type concurrency() :: number() | concurrency_option() | list(concurrency_option())

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

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

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

@type concurrency() :: number() | concurrency_option() | list(concurrency_option()) | nil

@type concurrency_option() ::
%{
limit: number(),
key: binary() | nil,
scope: binary() | nil
}
| nil
@concurrency_scopes ["fn", "env", "account"]

@type cancel_on() :: cancel_on() | list(cancel_on())
@type cancel_on() :: cancel_option() | list(cancel_option()) | nil

@type cancel_option() :: %{
event: binary(),
Expand Down

0 comments on commit cd4916e

Please sign in to comment.