Skip to content

RequestCoordinator

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:58

Manages the request lifecycle: sending requests, tracking in-flight state, emitting processing events, and coordinating flush promises.

const coordinator = new RequestCoordinator(connector);
coordinator.events.on('processing_completed', (e) => console.log(`Done in ${e.durationMs}ms`));
const response = await coordinator.send(envelope);

new RequestCoordinator(connector, options?): RequestCoordinator

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:68

EngineConnector

RequestCoordinatorOptions = {}

RequestCoordinator

readonly events: EventSubscriber<RequestCoordinatorEvents>

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:61


readonly store: Store<RequestCoordinatorState>

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:63

get isProcessing(): boolean

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:80

boolean


get lastResponse(): MaelstromResponse | null

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:84

MaelstromResponse | null

dispose(): void

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:200

Retire request error reporting and reject queued flush promises. Outstanding sends still settle with their transport outcome; this method does not disconnect the transport.

void


queueFlush(): Promise<MaelstromResponse | null>

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:159

Returns a promise that settles when the next response arrives or the next flush failure occurs. Use this to await an in-flight request when isProcessing is true and you want to coalesce with it.

Resolves to null rather than a response when the in-flight request it was coalescing with turns out to have been superseded (see resolveFlushPromises) — mirroring the null a caller already gets back from flushUpdates() when there was nothing to report.

Promise<MaelstromResponse | null>


rejectFlushPromises(error): void

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:188

Rejects all queued flush promises and clears the queue. Called when a flush fails before a response is available. The caller is responsible for logging if the error has not already been logged upstream — this method does not log.

Error

void


resolveFlushPromises(response): void

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:175

Resolves all queued flush promises and clears the queue.

Pass null when the request they were coalescing with was discarded (e.g. fenced out by a connector swap) rather than actually applied — resolving with the discarded response itself would hand callers a layout that was never dispatched, and every fenced call site must settle these promises somehow or they hang until an unrelated later request happens to resolve them with an irrelevant response.

MaelstromResponse | null

void


send(message): Promise<MaelstromResponse>

Defined in: packages/client/src/lib/orchestrator/request-coordinator.ts:106

Send a request and preserve its transport outcome for the caller. Failures received after disposal no longer report a live request error.

ChartRequestMessage

Promise<MaelstromResponse>