TypeDBLiteReplicator
Defined in: libs/runtime/src/typedblite-replicator.ts:86
Replicates a local change log against a remote hub over HTTP.
replicateOnce drains in both directions and returns; replicateContinuously holds an SSE
subscription open and pushes local work as it appears.
Member summary
Section titled “Member summary”Constructors
| Name | Description |
|---|---|
| new TypeDBLiteReplicator() | Creates a replicator for one store and one hub. |
Methods
| Name | Description |
|---|---|
| replicateContinuously() | Replicates continuously, until the session is canceled: holds a subscription to the hub open and pushes local changes as they appear. |
| replicateOnce() | Replicates once in the requested direction, then returns. |
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TypeDBLiteReplicator(
log,hubUrl,pushIntervalMs?,headers?):TypeDBLiteReplicator
Defined in: libs/runtime/src/typedblite-replicator.ts:97
Creates a replicator for one store and one hub.
Parameters
Section titled “Parameters”The local store’s change log (db.changeLog).
hubUrl
Section titled “hubUrl”string
The hub’s base URL.
pushIntervalMs?
Section titled “pushIntervalMs?”number = 100
How often a continuous replication pushes local changes. Default 100.
headers?
Section titled “headers?”() => Record<string, string> | Promise<Record<string, string>>
Headers for every request, called per request: a bearer token, for a hub that wants one.
Returns
Section titled “Returns”TypeDBLiteReplicator
Methods
Section titled “Methods”replicateContinuously()
Section titled “replicateContinuously()”replicateContinuously(
options,events?):ReplicationSession
Defined in: libs/runtime/src/typedblite-replicator.ts:182
Replicates continuously, until the session is canceled: holds a subscription to the hub open and pushes local
changes as they appear. Being caught up reports ready and keeps the subscription running.
Parameters
Section titled “Parameters”options
Section titled “options”events?
Section titled “events?”ReplicationEvents = {}
Returns
Section titled “Returns”replicateOnce()
Section titled “replicateOnce()”replicateOnce(
options):Promise<{applied:number;conflicts:number;cursor:SyncCursor; }>
Defined in: libs/runtime/src/typedblite-replicator.ts:112
Replicates once in the requested direction, then returns. Resume from the returned cursor.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<{ applied: number; conflicts: number; cursor: SyncCursor; }>
Throws
Section titled “Throws”if the hub does not answer within options.timeoutMs, or the request fails.
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.