Skip to content

FUZD / @fuzd/common / ProcessingBudget

Type Alias: ProcessingBudget ​

ProcessingBudget: object

How much one processing run (processQueue, processPendingTransactions) may do. A run keeps pulling batches of due items until one of these is reached, so a burst of items all due at the same time is drained by a few runs instead of a fixed handful per run.

The defaults fit a Cloudflare Worker cron (30s of CPU, a capped number of D1 queries per invocation, one run per minute): about 100 executions at roughly 9 statements each, finished well before the next run starts.

Type declaration ​

batchSize ​

batchSize: number

items fetched from storage at once

concurrency ​

concurrency: number

items handled at the same time, the items of one group (one account) are never concurrent

leaseDurationMs ​

leaseDurationMs: number

how long the items a run claimed stay its own (docs/adr/0004-claim-due-items-with-a-lease.md): other runs skip them until the run writes them back or the lease expires (a run that crashed). Well above how long a run takes, or two runs could hold the same item.

maxDurationPerRunMs ​

maxDurationPerRunMs: number

stop pulling new batches after this long, so a run is over before the next one starts

maxItemsPerRun ​

maxItemsPerRun: number

stop pulling new batches after this many items

Defined in ​

processing.ts:10