Skip to main content

Interface: CallGroupStore

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

Where call groups live. InMemoryCallGroupStore is the single-process default; @baleybots/postgres ships PostgresCallGroupStore.

Every conditional write resolves whether it applied, so concurrent instances racing on one call cannot both move it.

A store over a database its migration has not reached answers reads with nothing (no group, no calls, an empty sweep page), so createCallGroups' readers report nothing instead of failing; writes still fail.

Methods​

findCallByTicket()​

findCallByTicket(rootTicketId): Promise<Call<unknown> | null>

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

The call whose root ticket this is (one indexed read).

Parameters​

rootTicketId​

string

Returns​

Promise<Call<unknown> | null>


getCall()​

getCall(callId): Promise<Call<unknown> | null>

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

Parameters​

callId​

string

Returns​

Promise<Call<unknown> | null>


getGroup()​

getGroup(groupId): Promise<CallGroup | null>

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

Parameters​

groupId​

string

Returns​

Promise<CallGroup | null>


listCalls()​

listCalls(groupId, page): Promise<Call<unknown>[]>

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

A page of a group's calls, by ordinal.

Parameters​

groupId​

string

page​
afterOrdinal?​

number

dispatchState?​

CallDispatchState

limit​

number

unsettledOnly?​

boolean

Returns​

Promise<Call<unknown>[]>


listGroups()​

listGroups(query): Promise<CallGroup[]>

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

Groups for one coordinator, newest first.

Parameters​

query​
coordinator​

string

groupIds?​

readonly string[]

limit​

number

requestId?​

string

Returns​

Promise<CallGroup[]>


markDispatched()​

markDispatched(callId, ticketId): Promise<boolean>

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

pending → dispatched.

Parameters​

callId​

string

ticketId​

string

Returns​

Promise<boolean>


markRefused()​

markRefused(callId, reason): Promise<boolean>

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

pending → refused, settled refused.

Parameters​

callId​

string

reason​

string

Returns​

Promise<boolean>


persist()​

persist(group, calls): Promise<{ created: boolean; group: CallGroup; }>

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

Persist a group and its calls atomically, before any dispatch. Idempotent: a retried identical send meets its own rows. Throws CallGroupConflictError when the id exists for a different coordinator or tenant.

Parameters​

group​

NewCallGroup

calls​

readonly NewCall[]

Returns​

Promise<{ created: boolean; group: CallGroup; }>


settle()​

settle(callId, outcome, detail?): Promise<boolean>

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

Stamp an outcome on a call that has none yet.

Parameters​

callId​

string

outcome​

CallOutcome

detail?​
outcomeTicketId?​

string

refusedReason?​

string

Returns​

Promise<boolean>


summary()​

summary(groupId): Promise<{ counts: CallGroupCounts; group: CallGroup; } | null>

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

A group and its counts, in one read (no lock).

Parameters​

groupId​

string

Returns​

Promise<{ counts: CallGroupCounts; group: CallGroup; } | null>


sweepPending()​

sweepPending(page): Promise<object[]>

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

Pending calls not touched since olderThan, oldest first, each with its group.

Parameters​

page​
limit​

number

olderThan​

number

Returns​

Promise<object[]>


sweepReturns()​

sweepReturns(page): Promise<CallGroup[]>

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

Groups whose return looks due and that were not touched since olderThan, oldest first.

Parameters​

page​
limit​

number

olderThan​

number

Returns​

Promise<CallGroup[]>


sweepUnsettled()​

sweepUnsettled(page): Promise<Call<unknown>[]>

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

Dispatched, unsettled calls not touched since olderThan, oldest first.

Parameters​

page​
limit​

number

olderThan​

number

Returns​

Promise<Call<unknown>[]>


touchCall()​

touchCall(callId): Promise<void>

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

Move a call to the back of the sweep's queue.

Parameters​

callId​

string

Returns​

Promise<void>


touchGroup()​

touchGroup(groupId): Promise<void>

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

Move a group to the back of the sweep's queue.

Parameters​

groupId​

string

Returns​

Promise<void>


withGroupLock()​

withGroupLock<T>(groupId, fn): Promise<T | null>

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

Run fn holding the group's row lock, in one transaction with whatever it writes (the stamp, and the wake the hooks write on tx). Resolves null when the group does not exist.

Type Parameters​

T​

T

Parameters​

groupId​

string

fn​

(locked) => Promise<T>

Returns​

Promise<T | null>