Skip to main content

Class: InMemoryCallGroupStore

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:24

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.

Implements​

Constructors​

Constructor​

new InMemoryCallGroupStore(now?): InMemoryCallGroupStore

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:30

Parameters​

now?​

() => number

Returns​

InMemoryCallGroupStore

Methods​

findCallByTicket()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:92

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

Parameters​

rootTicketId​

string

Returns​

Promise<Call<unknown> | null>

Implementation of​

CallGroupStore.findCallByTicket


getCall()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:87

Parameters​

callId​

string

Returns​

Promise<Call<unknown> | null>

Implementation of​

CallGroupStore.getCall


getGroup()​

getGroup(groupId): Promise<CallGroup | null>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:57

Parameters​

groupId​

string

Returns​

Promise<CallGroup | null>

Implementation of​

CallGroupStore.getGroup


listCalls()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:67

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>[]>

Implementation of​

CallGroupStore.listCalls


listGroups()​

listGroups(query): Promise<CallGroup[]>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:77

Groups for one coordinator, newest first.

Parameters​

query​
coordinator​

string

groupIds?​

readonly string[]

limit​

number

requestId?​

string

Returns​

Promise<CallGroup[]>

Implementation of​

CallGroupStore.listGroups


markDispatched()​

markDispatched(callId, ticketId): Promise<boolean>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:104

pending → dispatched.

Parameters​

callId​

string

ticketId​

string

Returns​

Promise<boolean>

Implementation of​

CallGroupStore.markDispatched


markRefused()​

markRefused(callId, reason): Promise<boolean>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:108

pending → refused, settled refused.

Parameters​

callId​

string

reason​

string

Returns​

Promise<boolean>

Implementation of​

CallGroupStore.markRefused


persist()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:40

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; }>

Implementation of​

CallGroupStore.persist


settle()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:112

Stamp an outcome on a call that has none yet.

Parameters​

callId​

string

outcome​

CallOutcome

detail?​
outcomeTicketId?​

string

refusedReason?​

string

Returns​

Promise<boolean>

Implementation of​

CallGroupStore.settle


summary()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:62

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

Parameters​

groupId​

string

Returns​

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

Implementation of​

CallGroupStore.summary


sweepPending()​

sweepPending(page): Promise<object[]>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:161

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

Parameters​

page​
limit​

number

olderThan​

number

Returns​

Promise<object[]>

Implementation of​

CallGroupStore.sweepPending


sweepReturns()​

sweepReturns(page): Promise<CallGroup[]>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:177

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

Parameters​

page​
limit​

number

olderThan​

number

Returns​

Promise<CallGroup[]>

Implementation of​

CallGroupStore.sweepReturns


sweepUnsettled()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:169

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

Parameters​

page​
limit​

number

olderThan​

number

Returns​

Promise<Call<unknown>[]>

Implementation of​

CallGroupStore.sweepUnsettled


touchCall()​

touchCall(callId): Promise<void>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:120

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

Parameters​

callId​

string

Returns​

Promise<void>

Implementation of​

CallGroupStore.touchCall


touchGroup()​

touchGroup(groupId): Promise<void>

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:125

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

Parameters​

groupId​

string

Returns​

Promise<void>

Implementation of​

CallGroupStore.touchGroup


withGroupLock()​

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

Defined in: packages/orchestration/src/calls/in-memory-call-group-store.ts:130

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>

Implementation of​

CallGroupStore.withGroupLock