Skip to content

HttpStreamSession

Defined in: src/client/stream.ts:82

StreamSession implementation for the HTTP transport. Stream state is carried statelessly across requests via an HMAC state token: each HttpStreamSession.exchange or producer-continuation POST sends the current token and receives the next one in the response metadata.

new HttpStreamSession(opts): HttpStreamSession;

Defined in: src/client/stream.ts:106

Parameter Type
opts { authorization?: string; baseUrl: string; callStateToken?: string | null; compressFn?: CompressFn; compressionLevel?: number; decompressFn?: DecompressFn; externalConfig?: ExternalLocationConfig; finished: boolean; header: Record<string, any> | null; inputSchema?: Schema<any>; method: string; onLog?: (msg) => void; outputSchema: Schema; pendingBatches: RecordBatch<any>[]; postFn?: PostFn; prefix: string; stateToken: string | null; }
opts.authorization? string
opts.baseUrl string
opts.callStateToken? string | null
opts.compressFn? CompressFn
opts.compressionLevel? number
opts.decompressFn? DecompressFn
opts.externalConfig? ExternalLocationConfig
opts.finished boolean
opts.header Record<string, any> | null
opts.inputSchema? Schema<any>
opts.method string
opts.onLog? (msg) => void
opts.outputSchema Schema
opts.pendingBatches RecordBatch<any>[]
opts.postFn? PostFn
opts.prefix string
opts.stateToken string | null

HttpStreamSession

get header(): Record<string, any> | null;

Defined in: src/client/stream.ts:154

The stream’s one-time header row, or null if the method declares no header.

Record<string, any> | null

The method’s header row (returned once at stream start), or null if the method declares no header.

StreamSession.header

asyncIterator: AsyncIterableIterator<Record<string, any>[]>;

Defined in: src/client/stream.ts:317

Iterate over producer stream batches.

AsyncIterableIterator<Record<string, any>[]>

StreamSession.[asyncIterator]


close(): void;

Defined in: src/client/stream.ts:495

No-op: the HTTP transport is stateless, so there is nothing to tear down.

void

StreamSession.close


exchange(input): Promise<Record<string, any>[]>;

Defined in: src/client/stream.ts:211

Send an exchange request and return the data rows.

Parameter Type
input Record<string, any>[]

Promise<Record<string, any>[]>

StreamSession.exchange


nextWithToken(): Promise<RowsWithToken | null>;

Defined in: src/client/stream.ts:390

Read one producer batch and surface the worker’s continuation token.

Reads exactly one data batch and returns it paired with the resume token that continues the stream AFTER that batch — the worker’s own serialized producer state. A fresh session positioned at that token (see HttpStreamSession.seekToToken / the client’s resumeStream) resumes on any node, which is the basis for stateless, load-balanced relays that must not pin a scan to one process.

Returns null at end-of-stream. Requires per-batch continuation tokens (the default server behaviour — i.e. the worker is not configured with max_response_bytes); throws if a single response carries more than one data batch (coarser-than-batch resume is not representable here).

Drives the same wire protocol as async iteration but yields one { rows, token } per call instead of auto-following the token. Do not interleave with iteration/exchange on the same session.

Mirrors Python’s HttpStreamSession.next_with_token.

Promise<RowsWithToken | null>


seekToToken(token): void;

Defined in: src/client/stream.ts:464

Reposition a freshly-initialised session to resume from token.

Discards any init-preloaded batches and points the session at the given resume token (as returned by HttpStreamSession.nextWithToken), so the next nextWithToken() continues from exactly there. Used to resume a scan on a new process/node — which is why the call token travels inside the blob too: that node may never have seen this stream’s /init. Mirrors Python’s seek_to_token.

Parameter Type
token string

void