ChangeStreamClient
Defined in: libs/runtime/src/change-stream-client.ts:102
The spoke’s side of a hub’s change stream: subscribes to the hub’s server-sent events and pushes revisions to it. Reconnects on a dropped connection, resuming from the last change it delivered.
Member summary
Section titled “Member summary”Constructors
| Name | Description |
|---|---|
| new ChangeStreamClient() | Creates a client for one hub. |
Properties
| Name | Description |
|---|---|
| url | Public so a replicator can read the stream once without reaching into a private field. |
Accessors
| Name | Description |
|---|---|
| lastEventId | The seq of the last change delivered, which a reconnect resumes from. |
Methods
| Name | Description |
|---|---|
| push() | Push revisions to the hub, and resolve to how many it applied. |
| requestHeaders() | The extra headers for the next request (empty when none were configured). |
| subscribe() | Subscribe to the hub’s change stream, handing each change to handlers. |
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ChangeStreamClient(
url,options?):ChangeStreamClient
Defined in: libs/runtime/src/change-stream-client.ts:114
Creates a client for one hub.
Parameters
Section titled “Parameters”string
The hub’s base URL. Changes are read and pushed at <url>/changes.
options?
Section titled “options?”ChangeStreamClientOptions = {}
How it retries, and the headers to send.
Returns
Section titled “Returns”ChangeStreamClient
Properties
Section titled “Properties”
readonlyurl:string
Defined in: libs/runtime/src/change-stream-client.ts:116
Public so a replicator can read the stream once without reaching into a private field.
Accessors
Section titled “Accessors”lastEventId
Section titled “lastEventId”Get Signature
Section titled “Get Signature”get lastEventId():
number
Defined in: libs/runtime/src/change-stream-client.ts:121
The seq of the last change delivered, which a reconnect resumes from.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”push()
Section titled “push()”push(
records,signal?):Promise<number>
Defined in: libs/runtime/src/change-stream-client.ts:131
Push revisions to the hub, and resolve to how many it applied. The other half of duplex — SSE has no back-channel.
Parameters
Section titled “Parameters”records
Section titled “records”readonly ChangeRecord[]
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<number>
requestHeaders()
Section titled “requestHeaders()”requestHeaders():
Promise<Record<string,string>>
Defined in: libs/runtime/src/change-stream-client.ts:126
The extra headers for the next request (empty when none were configured).
Returns
Section titled “Returns”Promise<Record<string, string>>
subscribe()
Section titled “subscribe()”subscribe(
handlers,from?):ChangeStreamSubscription
Defined in: libs/runtime/src/change-stream-client.ts:153
Subscribe to the hub’s change stream, handing each change to handlers. Reconnects on a dropped connection, resuming from Last-Event-ID.
Parameters
Section titled “Parameters”handlers
Section titled “handlers”number = 0
Returns
Section titled “Returns”TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.