Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple concurrency limits and scopes #370

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 32 additions & 1 deletion packages/inngest/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,37 @@
}
>;

export interface ConcurrencyOption {
/**
* The concurrency limit for this option, adding a limit on how many concurrent
* steps can execute at once.
*/
limit: number;

/**
* An optional concurrency key, as an expression using the common expression language
* (CEL). The result of this expression is used to create new concurrency groups, or
* sub-queues, for each function run.
*
* The event is passed into this expression as "event".
*
* Examples:
* - `event.data.user_id`: this evaluates to the user_id in the event.data object.
* - `event.data.user_id + "-" + event.data.account_id`: creates a new group per user/account
* - `"ai"`: references a custom string
*/
key?: string;

/**
* An optional scope for the concurrency group. By default, concurrency limits are
* scoped to functions - one function's concurrency limits do not impact other functions.
*
* Changing this "scope" allows concurrency limits to work across environments (eg. production
* vs branch environments) or across your account (global).
*/
scope?: "fn" | "env" | "account"

Check warning on line 685 in packages/inngest/src/types.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`
}

/**
* A set of options for configuring an Inngest function.
*
Expand Down Expand Up @@ -685,7 +716,7 @@
*
* Specifying just a number means specifying only the concurrency limit.
*/
concurrency?: number | { limit: number; key?: string };
concurrency?: number | ConcurrencyOption | [ConcurrencyOption, ConcurrencyOption];

Check warning on line 719 in packages/inngest/src/types.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `·number·|·ConcurrencyOption` with `⏎····|·number⏎····|·ConcurrencyOption⏎···`
jpwilliams marked this conversation as resolved.
Show resolved Hide resolved

/**
* batchEvents specifies the batch configuration on when this function
Expand Down