s-m-r-t
Open the s-m-r-t source on GitHub Switch to dark color scheme
← All packages
Agents & runtime v0.44.0

@happyvertical/smrt-jobs

Persistent background work, schedules, retries, runners, queue controls, and operational visibility.

Source

What it gives you

Persistent background work, schedules, retries, runners, queue controls, and operational visibility.

  1. 01An opt-in allowlist for the methods a job row may call
  2. 02A per-tenant ceiling on in-flight jobs
  3. 03Retry counts clamped rather than trusted
  4. 04Automatic retention for terminal jobs and job events

Say which methods a job may call

A persisted job row names an object type and a method, so the runner must know which methods are reachable. Mark a method with the backgroundEligible decorator. For non-decorator code, call markBackgroundEligible. These operations add an allowlist to the class. A class that marks nothing keeps the default behavior. After one method is marked, the runner refuses every method outside the list.

One tenant cannot drain the queue

Enqueueing counts the non-terminal jobs for a tenant and refuses another job above the limit. The default limit is ten thousand, and each call or job builder can change it. A value of zero disables the check. Jobs without a tenant do not count against the limit. Requested retry counts are clamped to the supported maximum. Thus, a misconfigured caller cannot pin a worker on a poison job.

Retention starts after the runner is stable

TaskRunner schedules its first retention sweep one interval after start, never at startup. The default policy keeps completed or canceled jobs for seven days. It keeps failed jobs and events for thirty days. Dry-run cleanup is available before a deletion policy changes.