Featured image for Bulk cancellation API blog post

Bulk cancellation API

Tony Holdstock-Brown · 1/22/2024 · 2 min read

Queues are vital for smoothing demand in production systems. This works when throughput is stable, but sometimes you have too much demand, and your backlog grows without shrinking. It's also possible that a batch of faulty work is added to your backlog by an uncaught bug. In both cases it's important that you can easily manage your backlog to keep your systems operating smoothly.

Today, we're excited to announce a new bulk cancellation API, a feature that enables you to smartly prune your backlog in a simple, self-serve way. The API allows you to configure which functions to cancel, including both date ranges and selective cancellation using event data.

Selective and date-based cancellation

When managing your backlog, it's important that you cancel specific jobs causing issues while leaving other jobs running.

We're launching the API with selective cancellation. This lets you define an expression directly on the event data of the function run when bulk cancelling. If the expression returns true, the function is cancelled. For example:

json
{
// Only cancel functions pushed yesterday (Jan 21, 2024) if the vendor is Acme inc
"if": "event.data.vendor_id == 'acme_inc'",
"started_after": "2024-01-21T00:00:00Z",
"started_before": "2024-01-22T00:00:00Z",
"app_id": "billing",
"function_id": "vendor-syncs"
}

The API also lets you specify date ranges for cancellation. Any function started within this date range (exclusive) will be automatically cancelled any work needed from you.

These fields allow fine-grained control over your queue backlog, as opposed to the naive purge-all functionality provided by most clouds.

Immediate resolution

Inngest's cancellation API is immediate, and takes milliseconds to run. As soon as you hit the API, you can guarantee that matching functions will be cancelled. This helps you react quickly to incidents as they occur.

A compliment to existing declarative cancellation

Inngest already provides declarative cancellation, which allows you to cancel functions by sending events. This is useful for programmatically cancelling functions when changes occur in your system. Read more about this in our guide on cancelling functions.

Get started

Keeping production systems running with high reliability is important, and when you face production issues it's important that you have all of the tools available to operate smoothly and quickly.

To learn more about the cancellation API explore:

If you haven't started using Inngest yet read our quick-start guide.

Help shape the future of Inngest

Ask questions, give feedback, and share feature requests

Join our Discord!

Ready to start building?

Ship background functions & workflows like never before

$ npx inngest-cli devGet started for free