feat(sdk,core,webapp,run-engine): declare queue gates on tasks and triggers - #4827
feat(sdk,core,webapp,run-engine): declare queue gates on tasks and triggers#4827matt-aitken wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 5249200 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
03c5b34 to
d0d9e38
Compare
…iggers The queue option on task() and on trigger now accepts an array: the first entry is the queue the run waits in, the rest (at most two) are gates the run must also hold a concurrency slot in while executing. A gate without a concurrencyKey inherits the run's own key; a literal key pins the gate to one shared slot pool. Task-level gates apply to every trigger; a trigger array replaces them for that run. Gates persist on BackgroundWorkerTask (task defaults, carried through the task metadata cache with no extra trigger-time queries) and on TaskRun (replay fidelity and payload rebuilds), and flow into the run queue message where the engine enforces them behind its flag.
The queue tuple types now reject more than two gate entries at compile time, matching the wire schemas. Trigger body construction normalizes the queue option once per call site through a shared helper instead of three times, and cached task metadata runs gates through the same parser as database reads.
d0d9e38 to
512ff9c
Compare
…mpty gate names The dedicated run-ops TaskRun schema gains the same nullable gates column and migration so run creation keeps working with run-operations splitting enabled (the schema parity test covers it). Gate names and keys are also required to be non-empty everywhere they enter, so a configured gate can never be silently dropped by sanitization.
Summary
Stacked on #4826. Makes queue gates declarable: the
queueoption ontask()and ontrigger()now accepts an array where the first entry is the queue the run waits in and up to two more name gates, other queues the run must also hold a concurrency slot in while it executes.A gate without a
concurrencyKeyinherits the run's own key (thetenantgate above caps each tenant at 10 across every task that names it); a literal key pins the gate to one shared slot pool (a cap on all traffic to one external provider). A trigger-time array replaces the task's gates for that run. This structure also makes head-of-line blocking benign by construction: a gate's key is always the run's own key or a constant, so a message waiting on a full gate only ever holds up messages that would wait on the same gate.Design
The SDK normalizes the array into the home queue plus a
gateslist at its boundaries, so the wire format and storage stay explicit. Task-level gates persist on the worker task record and ride the existing task metadata cache, which keeps the trigger path at its current query count; per-trigger gates arrive in the request options and win over the task's. The resolved list is stored on the run (replays and every payload rebuild reuse it) and flows into the run queue message that #4826 enforces.Both migrations are additive nullable columns. Covered by an end-to-end engine test (trigger persists gates on the run; a full gate holds the next run queued) plus the existing trigger service tests.