drain
@forge/monorepo / backend/src / drain
Function: drain()
drain(
pruner,input):Promise<{batches:number;deleted:number;drained:boolean; }>
Defined in: backend/src/retention/index.ts:89
Drain a backlog by calling prune until it stops removing rows.
A helper rather than a loop inside prune, because the two have different failure modes: one long call that
dies halfway leaves an operator with no idea how far it got, whereas a loop over bounded calls has made
durable progress after every iteration.
maxBatches is a required ceiling, not an optional one. A loop whose termination depends on the database
eventually returning zero is a loop that runs forever the day a bug makes prune return a positive count
without deleting anything — and it would run forever inside a maintenance job, where nobody is watching.
Parameters
pruner
input
PruneRequest & object
Returns
Promise<{ batches: number; deleted: number; drained: boolean; }>