diff --git a/packages/inngest/CHANGELOG.md b/packages/inngest/CHANGELOG.md index d77952356..571657a34 100644 --- a/packages/inngest/CHANGELOG.md +++ b/packages/inngest/CHANGELOG.md @@ -1,5 +1,15 @@ # inngest +## 3.4.0 + +### Minor Changes + +- [#370](https://github.com/inngest/inngest-js/pull/370) [`48b201a`](https://github.com/inngest/inngest-js/commit/48b201a90f343a1927f38118b732615f77f9ca7f) Thanks [@tonyhb](https://github.com/tonyhb)! - Update concurrency with new scopes and multiple keys + +### Patch Changes + +- [#369](https://github.com/inngest/inngest-js/pull/369) [`e1046cd`](https://github.com/inngest/inngest-js/commit/e1046cd62430b5599512eb697ebf5ac3fbfd6bb6) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Change `No request version` log from warn to debug + ## 3.3.0 ### Minor Changes diff --git a/packages/inngest/etc/inngest.api.md b/packages/inngest/etc/inngest.api.md index d4794b3cb..b7445ef63 100644 --- a/packages/inngest/etc/inngest.api.md +++ b/packages/inngest/etc/inngest.api.md @@ -97,10 +97,8 @@ export interface FunctionOptions, Ev // // (undocumented) cancelOn?: Cancellation[]; - concurrency?: number | { - limit: number; - key?: string; - }; + // Warning: (ae-forgotten-export) The symbol "ConcurrencyOption" needs to be exported by the entry point index.d.ts + concurrency?: number | ConcurrencyOption | [ConcurrencyOption, ConcurrencyOption]; debounce?: { key?: string; period: TimeStr; @@ -429,7 +427,7 @@ export type ZodEventSchemas = Record((v) => { if (typeof v === "undefined") { - console.warn( + console.debug( `No request version specified by executor; defaulting to v${PREFERRED_EXECUTION_VERSION}` ); diff --git a/packages/inngest/src/types.ts b/packages/inngest/src/types.ts index 2c775d713..a13af03c2 100644 --- a/packages/inngest/src/types.ts +++ b/packages/inngest/src/types.ts @@ -660,6 +660,37 @@ export type TriggerOptions = StrictUnion< } >; +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"; +} + /** * A set of options for configuring an Inngest function. * @@ -691,7 +722,7 @@ export interface FunctionOptions< * * Specifying just a number means specifying only the concurrency limit. */ - concurrency?: number | { limit: number; key?: string }; + concurrency?: number | ConcurrencyOption | [ConcurrencyOption, ConcurrencyOption]; /** * batchEvents specifies the batch configuration on when this function