enqueue

tcmts.server.enqueue · #xmwcdckl · term · runs on the server

uses #tcm/host (enqueue)

Run fn(...args) in the background, soon, with retries (5 attempts, exponential backoff); returns the job id. fn must be a codebase function: the job records its hash, so it runs the code version that enqueued it. Arguments must be plain data. In a transaction, the job is queued when it commits.

import { enqueue as hostEnqueue } from "#tcm/host";

export function enqueue<A extends unknown[]>(fn: (...args: A) => unknown, ...args: A): string {
  return hostEnqueue(Date.now(), fn as (...args: unknown[]) => unknown, args);
}

used by