Function run priority v3.2.1+
TypeScript SDK v4 is now in beta. See the v4 docs and migration guide.
You can prioritize specific function runs above other runs within the same function.
See the Priority guide for more information about how this feature works.
export default inngest.createFunction(
{
id: "ai-generate-summary",
priority: {
// For enterprise accounts, a given function run will be prioritized
// ahead of functions that were enqueued up to 120 seconds ago.
// For all other accounts, the function will run with no priority.
run: "event.data.account_type == 'enterprise' ? 120 : 0",
},
},
{ event: "ai/summary.requested" },
async ({ event, step }) => {
// This function will be prioritized based on the account type
}
);
Configuration
- Name
priority- Type
- object
- Required
- optional
- Description
Options to configure how to prioritize functions
Properties- Name
run- Type
- string
- Required
- optional
- Description
An expression which must return an integer between -600 and 600 (by default), with higher return values resulting in a higher priority.
Expressions are defined using the Common Expression Language (CEL) with the original event accessible using dot-notation. Read our guide to writing expressions for more info. Examples:
- Return the priority within an event directly:
event.data.priority(whereevent.data.priorityis an int within your account's range) - Prioritize by a string field:
event.data.plan == 'enterprise' ? 180 : 0
- Return the priority within an event directly:
Return values outside of your account's range (by default, -600 to 600) will automatically be clipped to your max bounds.
An invalid expression will evaluate to 0, as in "no priority".