Methods
(static) apiPipelineAddPending(pipe, requestId, index, node) → {void}
Records a submitted request as in flight.
| Name | Type | Description |
|---|---|---|
pipe | object | |
requestId | string | |
index | integer | |
node | dynamic |
- Source
- Type:
- void
(static) apiPipelineBegin(entries, budgetMsopt) → {dynamic}
Starts a pipeline run over entries.
entries is empty / invalid
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
entries | dynamic | array of AAs, each { requestId: string, req: AA, ...payload } | ||
budgetMs | integer | <optional> | timeouts.PIPELINE_RUN_MS | whole-run deadline in ms; defaults to timeouts.PIPELINE_RUN_MS |
- Source
an opaque pipe state AA to pass to apiPipelineNext(), or invalid if
- Type:
- dynamic
(static) apiPipelineBudgetSpent(budgetMs, elapsedMs) → {boolean}
Has the whole-run deadline passed?
Small enough to inline, but named and separate on purpose: the clock lives in the shell and is therefore untestable, whereas this predicate is pinned by unit tests — including that the deadline counts as spent AT zero rather than one tick later. Any second budget check added later must call this rather than re-derive the comparison; two hand-written checks disagreeing is precisely the bug that a post-completion refill introduced here once.
| Name | Type | Description |
|---|---|---|
budgetMs | integer | |
elapsedMs | integer |
- Type:
- boolean
(static) apiPipelineClaimNext(pipe) → {dynamic}
Claims the next queued entry for submission and advances the cursor, so an entry can never be submitted twice.
| Name | Type | Description |
|---|---|---|
pipe | object |
- Source
an AA { entry, index, node: invalid }, or invalid when the queue is empty
- Type:
- dynamic
(static) apiPipelineDrainOne(pipe) → {dynamic}
Yields the next entry that will never be delivered, once the budget is spent: in-flight requests first (lowest entry index first), then unsubmitted ones in entry order. Returns invalid when nothing is left.
| Name | Type | Description |
|---|---|---|
pipe | object |
- Type:
- dynamic
(static) apiPipelineEnd(pipe) → {void}
Releases every still-in-flight request without waiting for it. Only needed by a caller that abandons the run early (breaking out of the loop before apiPipelineNext returns invalid) — a run driven to exhaustion has already released everything. Idempotent; safe on a finished pipe.
A late pool response after this writes to an abandoned result node and is ignored, exactly as fetchRes's timeout path leaves its node behind.
| Name | Type | Description |
|---|---|---|
pipe | dynamic |
- Source
- Type:
- void
(static) apiPipelineEventRequestId(msg) → {dynamic}
Recovers the requestId from an isDone event. submitApiRequest stamps it onto the request AA the result node carries; the node's own id is left unset.
| Name | Type | Description |
|---|---|---|
msg | object |
- Type:
- dynamic
(static) apiPipelineHasQueued(pipe) → {boolean}
Are there entries that have not been submitted yet?
| Name | Type | Description |
|---|---|---|
pipe | object |
- Source
- Type:
- boolean
(static) apiPipelineIsDone(pipe) → {boolean}
A run is finished only when nothing is queued AND nothing is in flight — an empty queue with requests still outstanding is not done.
| Name | Type | Description |
|---|---|---|
pipe | object |
- Source
- Type:
- boolean
(static) apiPipelineNext(pipe) → {dynamic}
Advances the pipeline: tops the pool up to its slot count, then blocks until one request completes.
invalid if that entry never got an answer — or invalid when the run is exhausted (every entry has been yielded exactly once).
| Name | Type | Description |
|---|---|---|
pipe | dynamic | the AA from apiPipelineBegin() |
- Source
an AA { entry, res } for one entry — res is the pool response AA, or
- Type:
- dynamic
(static) apiPipelineRefill(pipe) → {void}
Submits queued entries until the pool is full or the queue is empty.
Best-effort by contract: an entry it cannot submit is put BACK on the queue (the claim is reverted) rather than consumed. That keeps the undeliverable path in one place — apiPipelineNext's top-up, which yields the entry to the caller with res = invalid. Without the revert, an entry claimed here and dropped would never be yielded at all, breaking the exactly-once guarantee.
| Name | Type | Description |
|---|---|---|
pipe | dynamic |
- Type:
- void
(static) apiPipelineRelease(record) → {void}
Drops the pool observer for a finished record. Records claimed but never submitted carry no node, so this is a no-op for them.
| Name | Type | Description |
|---|---|---|
record | dynamic |
- Type:
- void
(static) apiPipelineSlotsFree(pipe) → {integer}
How many more requests may be put in flight right now.
| Name | Type | Description |
|---|---|---|
pipe | object |
- Source
- Type:
- integer
(static) apiPipelineTake(pipe, requestId) → {dynamic}
Removes and returns the in-flight record for requestId, freeing its slot. Idempotent by design: an unknown or already-taken id returns invalid, so a duplicate or late event is a no-op rather than a double delivery.
| Name | Type | Description |
|---|---|---|
pipe | object | |
requestId | dynamic |
- Type:
- dynamic
(static) apiPipelineWaitMs(remainingMs) → {integer}
How long to block on one wait: never past the run budget, never longer than a single request's own deadline.
| Name | Type | Description |
|---|---|---|
remainingMs | integer |
- Type:
- integer