Skip to main content

Interface: CallGroupHooks<P>

Defined in: packages/orchestration/src/calls/types.ts:141

Host hooks. tx is the store's handle on the transaction the group's row lock is held in (PostgresCallGroupStore: the connection running it). Write the wake through it and the wake commits with the stamp, or neither does.

Type Parameters​

P​

P = unknown

Methods​

coordinatorState()​

coordinatorState(group, tx): Promise<CoordinatorState>

Defined in: packages/orchestration/src/calls/types.ts:176

Asked only when a wake was not taken. gone (deleted, done, stopped) closes the group; paused or active (its queue is full) is offered the return again later, behind every other group.

Parameters​

group​

CallGroup

tx​

unknown

Returns​

Promise<CoordinatorState>


dispatch()​

dispatch(call, group): Promise<CallDispatch>

Defined in: packages/orchestration/src/calls/types.ts:146

Dispatch one call. Must be idempotent per call.id — a retry (another instance, the sweep) is the same work and must name the same ticket.

Parameters​

call​

Call<P>

group​

CallGroup

Returns​

Promise<CallDispatch>


isHeld()?​

optional isHeld(call): Promise<"open" | "none" | "closed">

Defined in: packages/orchestration/src/calls/types.ts:160

A dispatched call with no chain yet may be held (for credit, say): open while it waits, closed once the hold resolved. Read before the chain is read again, so a ticket the hold's release created is never missed. Default none.

Parameters​

call​

Call<P>

Returns​

Promise<"open" | "none" | "closed">


isParked()?​

optional isParked(link, call): boolean | Promise<boolean>

Defined in: packages/orchestration/src/calls/types.ts:153

Whether a link is parked at its spend ceiling. Default: link.parked.

Parameters​

CallChainLink

call​

Call<P>

Returns​

boolean | Promise<boolean>


onError()?​

optional onError(context, error): void

Defined in: packages/orchestration/src/calls/types.ts:178

A dispatch, settlement or return that threw. The call or group stays where it was and the sweep retries it.

Parameters​

context​
callId?​

string

groupId​

string

phase​

"dispatch" | "settle" | "return"

error​

unknown

Returns​

void


readChain()?​

optional readChain(call): Promise<CallChainLink[]>

Defined in: packages/orchestration/src/calls/types.ts:151

The call's chain, oldest first. Default: the root ticket read from the tickets store passed to createCallGroups (a call is one ticket).

Parameters​

call​

Call<P>

Returns​

Promise<CallChainLink[]>


rootOf()?​

optional rootOf(ticketId): Promise<string | null>

Defined in: packages/orchestration/src/calls/types.ts:165

The root ticket of a ticket a call's chain may contain, for settleForTicket. Default: the ticket is its own root.

Parameters​

ticketId​

string

Returns​

Promise<string | null>


wake()​

wake(signal, tx): Promise<boolean>

Defined in: packages/orchestration/src/calls/types.ts:170

Wake the coordinator. Return true when it has the signal — including when an identical one (same ref) is already waiting for it.

Parameters​

signal​

CallReturnSignal

tx​

unknown

Returns​

Promise<boolean>