@delali/sirannon-db 0.3.4-next.62 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -56
- package/dist/backup/index.d.ts +44 -45
- package/dist/backup/index.mjs +7 -7
- package/dist/backup-scheduler/index.d.ts +42 -41
- package/dist/backup-scheduler/index.mjs +4 -4
- package/dist/baseline-Co3iIsN_.d.ts +19 -0
- package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
- package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
- package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
- package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
- package/dist/chunk-4KASJKKK.mjs +2501 -0
- package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
- package/dist/chunk-55YRLSM2.mjs +57 -0
- package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
- package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
- package/dist/chunk-ADNWEHGZ.mjs +299 -0
- package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
- package/dist/chunk-BVMZJOVM.mjs +5 -0
- package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
- package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
- package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
- package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
- package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
- package/dist/chunk-HR7K3GZW.mjs +36 -0
- package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
- package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
- package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
- package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
- package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
- package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
- package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
- package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
- package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
- package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
- package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
- package/dist/chunk-WOMADPM4.mjs +12 -0
- package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
- package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
- package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
- package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
- package/dist/client/index.d.ts +135 -137
- package/dist/client/index.mjs +177 -82
- package/dist/client/topology.d.ts +31 -31
- package/dist/client/topology.mjs +42 -23
- package/dist/client-base-BxTocU1x.d.ts +398 -0
- package/dist/client-streams-YKANXMWO.mjs +112 -0
- package/dist/codegen/cli.mjs +4 -4
- package/dist/codegen/index.d.ts +36 -29
- package/dist/codegen/index.mjs +4 -4
- package/dist/core/index.d.ts +130 -115
- package/dist/core/index.mjs +387 -297
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-CGDsXW1K.d.ts +959 -0
- package/dist/database-backup-DcLhxoa1.d.ts +143 -0
- package/dist/driver/better-sqlite3.d.ts +11 -10
- package/dist/driver/better-sqlite3.mjs +11 -11
- package/dist/driver/bun.d.ts +9 -8
- package/dist/driver/expo.d.ts +6 -7
- package/dist/driver/node.d.ts +11 -10
- package/dist/driver/node.mjs +13 -11
- package/dist/driver/wa-sqlite.d.ts +6 -6
- package/dist/errors-CJUkQ-KL.d.ts +199 -0
- package/dist/file-migrations/index.d.ts +20 -18
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
- package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
- package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
- package/dist/protocol-DFpNNsIT.d.ts +153 -0
- package/dist/query-types-5B02ixH0.d.ts +129 -0
- package/dist/react/index.d.ts +22 -22
- package/dist/replication/coordinator/etcd.d.ts +37 -31
- package/dist/replication/coordinator/etcd.mjs +296 -131
- package/dist/replication/index.d.ts +201 -161
- package/dist/replication/index.mjs +630 -529
- package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
- package/dist/server/index.d.ts +201 -191
- package/dist/server/index.mjs +736 -619
- package/dist/server-options-aYtCkefX.d.ts +317 -0
- package/dist/server-streams-24XL4T43.mjs +254 -0
- package/dist/sirannon-J3EgPVD7.d.ts +179 -0
- package/dist/transport/grpc.d.ts +37 -24
- package/dist/transport/grpc.mjs +83 -3199
- package/dist/transport/memory.d.ts +25 -26
- package/dist/transport/memory.mjs +18 -9
- package/dist/types-BrAiDGOb.d.ts +505 -0
- package/dist/types-CEJG0eFS.d.ts +88 -0
- package/dist/types-Dc8oWlxj.d.ts +1580 -0
- package/dist/types-DqODKeOq.d.ts +123 -0
- package/dist/types-guEKSzMr.d.ts +367 -0
- package/package.json +7 -7
- package/dist/baseline-D93hcIEE.d.ts +0 -17
- package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
- package/dist/client-base-Cmd9EVme.d.ts +0 -397
- package/dist/database-BLQvqjsw.d.ts +0 -917
- package/dist/database-backup-B7oszQ2n.d.ts +0 -141
- package/dist/errors-Dei4GdBb.d.ts +0 -196
- package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
- package/dist/primary-wins-B0np8JS3.d.ts +0 -85
- package/dist/protocol-HI-nY8DD.d.ts +0 -152
- package/dist/query-types-p1liOP-b.d.ts +0 -127
- package/dist/restore-options-CksYsH1l.d.ts +0 -83
- package/dist/server-options-Bj5iJnjx.d.ts +0 -292
- package/dist/sirannon-BPxC5tC2.d.ts +0 -178
- package/dist/types-B0EhgDbr.d.ts +0 -340
- package/dist/types-CbjfRwrK.d.ts +0 -499
- package/dist/types-CjhxcjhA.d.ts +0 -123
- package/dist/types-DPSmjU54.d.ts +0 -1518
- package/dist/types-DTO4CYhW.d.ts +0 -88
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { H as HookRegistry, M as MetricsCollector, D as Database, a as HookDispose } from './database-CGDsXW1K.js';
|
|
2
|
+
import { a as SirannonOptions, S as SQLiteDriver, D as DatabaseOptions, M as Migration, b as BeforeQueryHook, A as AfterQueryHook, c as BeforeConnectHook, d as DatabaseOpenHook, e as DatabaseCloseHook } from './types-Dc8oWlxj.js';
|
|
3
|
+
|
|
4
|
+
/** The outcome of taking one database offline.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
type OfflineOutcome<T> = {
|
|
8
|
+
/** True when the action returned. */
|
|
9
|
+
ok: true;
|
|
10
|
+
/** The value that the action returned. */
|
|
11
|
+
value: T;
|
|
12
|
+
/** The error that the reopen threw, when it threw; the action's result is still valid. */
|
|
13
|
+
reopenFailure?: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
/** False when the action threw. */
|
|
16
|
+
ok: false;
|
|
17
|
+
/** The error that the action threw. */
|
|
18
|
+
failure: unknown;
|
|
19
|
+
/** The error that the reopen threw, when it threw. */
|
|
20
|
+
reopenFailure?: unknown;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A registry of open SQLite databases, keyed by identifier.
|
|
25
|
+
*
|
|
26
|
+
* The registry opens every database through one driver and applies its hooks, metrics, and migrations to each one; when you configure a lifecycle, it also closes idle databases.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
declare class Sirannon {
|
|
31
|
+
private readonly dbs;
|
|
32
|
+
private readonly openedWith;
|
|
33
|
+
private readonly offline;
|
|
34
|
+
private readonly offlineWork;
|
|
35
|
+
private readonly opening;
|
|
36
|
+
private readonly resolving;
|
|
37
|
+
private _shutdown;
|
|
38
|
+
private readonly _driver;
|
|
39
|
+
private readonly _hookRegistry;
|
|
40
|
+
private readonly metricsCollector;
|
|
41
|
+
private readonly lifecycleManager;
|
|
42
|
+
private readonly migrations;
|
|
43
|
+
/** The driver, hooks, metrics, lifecycle, migrations, and writer-worker and retention defaults that this registry was constructed with. */
|
|
44
|
+
readonly options: SirannonOptions;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a registry.
|
|
47
|
+
*
|
|
48
|
+
* @param options - The driver, hooks, metrics, lifecycle, migrations, and the defaults for every database that the registry opens.
|
|
49
|
+
*/
|
|
50
|
+
constructor(options: SirannonOptions);
|
|
51
|
+
/** @internal */
|
|
52
|
+
get driver(): SQLiteDriver;
|
|
53
|
+
/** @internal */
|
|
54
|
+
get hookRegistry(): HookRegistry;
|
|
55
|
+
/** @internal */
|
|
56
|
+
get metrics(): MetricsCollector | null;
|
|
57
|
+
/**
|
|
58
|
+
* Opens a database and registers it under an identifier.
|
|
59
|
+
*
|
|
60
|
+
* @param id - The identifier that callers use to reach this database.
|
|
61
|
+
* @param path - The file path of the SQLite database.
|
|
62
|
+
* @param options - The pool size, journal mode, synchronous level, and change-capture settings.
|
|
63
|
+
* @returns The open database.
|
|
64
|
+
* @throws A `DatabaseAlreadyExistsError` when the identifier is already in use, or `DATABASE_OPEN_FAILED` when the open or a registry migration fails.
|
|
65
|
+
*/
|
|
66
|
+
open(id: string, path: string, options?: DatabaseOptions): Promise<Database>;
|
|
67
|
+
/**
|
|
68
|
+
* Closes one database and removes it from the registry.
|
|
69
|
+
*
|
|
70
|
+
* @param id - The identifier of the database to close.
|
|
71
|
+
*/
|
|
72
|
+
close(id: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Closes one database, calls an action on its file, and then opens that
|
|
75
|
+
* database again under the same identifier with its earlier settings.
|
|
76
|
+
*
|
|
77
|
+
* A restore rebuilds a database at its current path, so no connection may be
|
|
78
|
+
* open on that file while Sirannon replaces its bytes. {@link Sirannon.get}
|
|
79
|
+
* returns undefined for the identifier until the database is open again, and
|
|
80
|
+
* Sirannon reopens the database even after a failed action.
|
|
81
|
+
*
|
|
82
|
+
* @param id - The identifier of the database to take offline.
|
|
83
|
+
* @param action - The function that Sirannon calls with the database file path once the database is closed.
|
|
84
|
+
* @returns Whether the action returned, the value that it returned or the error that it threw, and any error that the reopen threw.
|
|
85
|
+
* @throws A `DatabaseNotFoundError` when no database is open under the identifier, a `ReadOnlyError` when the database is read-only, or the close error when the close fails.
|
|
86
|
+
*
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
withDatabaseOffline<T>(id: string, action: (path: string) => Promise<T>): Promise<OfflineOutcome<T>>;
|
|
90
|
+
/**
|
|
91
|
+
* Returns an already-open database.
|
|
92
|
+
*
|
|
93
|
+
* @param id - The identifier of the database.
|
|
94
|
+
* @returns The database, or undefined when none is open under that identifier.
|
|
95
|
+
*/
|
|
96
|
+
get(id: string): Database | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Returns an open database, and opens it through the lifecycle resolver when it is not open yet.
|
|
99
|
+
*
|
|
100
|
+
* An in-process application calls this for a database that the registry opens on first use
|
|
101
|
+
* through the `lifecycle.autoOpen` resolver, such as one file per tenant. Concurrent calls for
|
|
102
|
+
* the same unopened identifier share one open, so each call receives the same database or the
|
|
103
|
+
* same error.
|
|
104
|
+
*
|
|
105
|
+
* @param id - The identifier of the database.
|
|
106
|
+
* @returns The database, or undefined when none is open and the resolver returns no path for it.
|
|
107
|
+
*/
|
|
108
|
+
resolve(id: string): Promise<Database | undefined>;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the registry's migration set, which Sirannon applies to each writable database as it opens.
|
|
111
|
+
*
|
|
112
|
+
* When the set comes from a function, the registry calls that function once and caches the
|
|
113
|
+
* result, so this returns the same list on every call; after a failed load, the next call
|
|
114
|
+
* tries again.
|
|
115
|
+
*
|
|
116
|
+
* @returns The migrations declared in `SirannonOptions.migrations`, or an empty list when there are none.
|
|
117
|
+
*/
|
|
118
|
+
registryMigrations(): Promise<Migration[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Returns whether a database is open under an identifier.
|
|
121
|
+
*
|
|
122
|
+
* @param id - The identifier to check.
|
|
123
|
+
* @returns True when the registry has an open database under that identifier.
|
|
124
|
+
*/
|
|
125
|
+
has(id: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Returns every database that this registry has open.
|
|
128
|
+
*
|
|
129
|
+
* @returns A copy of the open databases, keyed by identifier.
|
|
130
|
+
*/
|
|
131
|
+
databases(): Map<string, Database>;
|
|
132
|
+
/**
|
|
133
|
+
* Closes every open database and stops the lifecycle timers.
|
|
134
|
+
*
|
|
135
|
+
* When Sirannon is replacing a database's file, the shutdown waits for that
|
|
136
|
+
* work to finish, because a process that exits part-way through the
|
|
137
|
+
* replacement can leave no database at the path.
|
|
138
|
+
*/
|
|
139
|
+
shutdown(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Registers a hook that Sirannon calls before each statement on every database in this registry; throw from the hook to reject the statement.
|
|
142
|
+
*
|
|
143
|
+
* @param hook - The hook, which Sirannon calls with the statement, its parameters, and its read or write concern.
|
|
144
|
+
* @returns A function that removes the hook.
|
|
145
|
+
*/
|
|
146
|
+
onBeforeQuery(hook: BeforeQueryHook): HookDispose;
|
|
147
|
+
/**
|
|
148
|
+
* Registers a hook that Sirannon calls after each statement on every database in this registry.
|
|
149
|
+
*
|
|
150
|
+
* @param hook - The hook, which Sirannon calls with the statement and its duration.
|
|
151
|
+
* @returns A function that removes the hook.
|
|
152
|
+
*/
|
|
153
|
+
onAfterQuery(hook: AfterQueryHook): HookDispose;
|
|
154
|
+
/**
|
|
155
|
+
* Registers a hook that Sirannon calls before it opens a database.
|
|
156
|
+
*
|
|
157
|
+
* @param hook - The hook, which Sirannon calls with the database identifier and file path.
|
|
158
|
+
* @returns A function that removes the hook.
|
|
159
|
+
*/
|
|
160
|
+
onBeforeConnect(hook: BeforeConnectHook): HookDispose;
|
|
161
|
+
/**
|
|
162
|
+
* Registers a hook that Sirannon calls once a database is open.
|
|
163
|
+
*
|
|
164
|
+
* @param hook - The hook, which Sirannon calls with the database identifier and file path.
|
|
165
|
+
* @returns A function that removes the hook.
|
|
166
|
+
*/
|
|
167
|
+
onDatabaseOpen(hook: DatabaseOpenHook): HookDispose;
|
|
168
|
+
/**
|
|
169
|
+
* Registers a hook that Sirannon calls once a database is closed.
|
|
170
|
+
*
|
|
171
|
+
* @param hook - The hook, which Sirannon calls with the database identifier and file path.
|
|
172
|
+
* @returns A function that removes the hook.
|
|
173
|
+
*/
|
|
174
|
+
onDatabaseClose(hook: DatabaseCloseHook): HookDispose;
|
|
175
|
+
private ensureRunning;
|
|
176
|
+
private ensureOpenAllowed;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { Sirannon as S };
|
package/dist/transport/grpc.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
2
2
|
import { Client, ClientDuplexStream, CallOptions, Metadata, ServiceError, ClientUnaryCall, ChannelCredentials, ClientOptions, ServerDuplexStream, Server } from '@grpc/grpc-js';
|
|
3
3
|
import { HealthImplementation } from 'grpc-health-check';
|
|
4
|
-
import { R as ReplicationAck, F as ForwardedTransaction, a as ForwardedTransactionResult, N as NodeInfo, S as SyncRequest, b as SyncBatch, c as SyncComplete, d as SyncAck, e as ReplicationTransport, f as TopologyRole, T as TransportConfig } from '../types-
|
|
5
|
-
import { R as ReplicationBatch } from '../types-
|
|
6
|
-
import '../change-tracker-
|
|
7
|
-
import '../types-
|
|
8
|
-
import '../query-types-
|
|
9
|
-
import '../types-
|
|
4
|
+
import { R as ReplicationAck, F as ForwardedTransaction, a as ForwardedTransactionResult, N as NodeInfo, S as SyncRequest, b as SyncBatch, c as SyncComplete, d as SyncAck, e as ReplicationTransport, f as TopologyRole, T as TransportConfig } from '../types-BrAiDGOb.js';
|
|
5
|
+
import { R as ReplicationBatch } from '../types-DqODKeOq.js';
|
|
6
|
+
import '../change-tracker-DqCdeEyx.js';
|
|
7
|
+
import '../types-Dc8oWlxj.js';
|
|
8
|
+
import '../query-types-5B02ixH0.js';
|
|
9
|
+
import '../types-guEKSzMr.js';
|
|
10
10
|
|
|
11
11
|
interface ColumnValue {
|
|
12
12
|
nullValue?: boolean | undefined;
|
|
@@ -144,6 +144,8 @@ interface ForwardRequest {
|
|
|
144
144
|
statements: Statement[];
|
|
145
145
|
groupId: string;
|
|
146
146
|
primaryTerm: bigint;
|
|
147
|
+
writeConcernLevel: string;
|
|
148
|
+
writeConcernTimeoutMs: number;
|
|
147
149
|
}
|
|
148
150
|
declare const ForwardRequest: MessageFns<ForwardRequest>;
|
|
149
151
|
interface StatementResult {
|
|
@@ -157,6 +159,7 @@ interface ForwardResponse {
|
|
|
157
159
|
error: string;
|
|
158
160
|
groupId: string;
|
|
159
161
|
primaryTerm: bigint;
|
|
162
|
+
errorCode: string;
|
|
160
163
|
}
|
|
161
164
|
declare const ForwardResponse: MessageFns<ForwardResponse>;
|
|
162
165
|
type ReplicationService = typeof ReplicationService;
|
|
@@ -238,37 +241,37 @@ declare function toColumnValue(value: unknown): ColumnValue;
|
|
|
238
241
|
declare function fromColumnValue(cv: ColumnValue): unknown;
|
|
239
242
|
|
|
240
243
|
/**
|
|
241
|
-
*
|
|
244
|
+
* Sets the address that the gRPC transport listens on and the certificates that it presents and trusts.
|
|
242
245
|
*
|
|
243
246
|
* @public
|
|
244
247
|
*/
|
|
245
248
|
interface GrpcReplicationOptions {
|
|
246
249
|
/**
|
|
247
|
-
*
|
|
250
|
+
* Sets the address that the gRPC server binds to. Defaults to '0.0.0.0'.
|
|
248
251
|
*/
|
|
249
252
|
host?: string;
|
|
250
253
|
/**
|
|
251
|
-
*
|
|
254
|
+
* Sets the port that the gRPC server binds to. The default, 0, lets the operating system pick a free port.
|
|
252
255
|
*/
|
|
253
256
|
port?: number;
|
|
254
257
|
/**
|
|
255
|
-
*
|
|
258
|
+
* Sets the path to this node's TLS certificate.
|
|
256
259
|
*/
|
|
257
260
|
tlsCert?: string;
|
|
258
261
|
/**
|
|
259
|
-
*
|
|
262
|
+
* Sets the path to this node's private key.
|
|
260
263
|
*/
|
|
261
264
|
tlsKey?: string;
|
|
262
265
|
/**
|
|
263
|
-
*
|
|
266
|
+
* Sets the path to the certificate authority certificate that this node verifies its peers against.
|
|
264
267
|
*/
|
|
265
268
|
tlsCaCert?: string;
|
|
266
269
|
/**
|
|
267
|
-
*
|
|
270
|
+
* Turns off TLS. Use it only in tests.
|
|
268
271
|
*/
|
|
269
272
|
insecure?: boolean;
|
|
270
273
|
/**
|
|
271
|
-
*
|
|
274
|
+
* Sets how many milliseconds a replica waits for a forwarded write before it fails the write. Defaults to 30000.
|
|
272
275
|
*/
|
|
273
276
|
forwardDeadlineMs?: number;
|
|
274
277
|
}
|
|
@@ -293,7 +296,8 @@ type SyncCompleteHandler = (complete: SyncComplete, fromPeerId: string) => Promi
|
|
|
293
296
|
type SyncAckHandler = (ack: SyncAck, fromPeerId: string) => void;
|
|
294
297
|
|
|
295
298
|
/**
|
|
296
|
-
*
|
|
299
|
+
* Sends replication messages between nodes over gRPC. Unless you set `insecure`, it requires `tlsCert` and `tlsKey`,
|
|
300
|
+
* and when you also set `tlsCaCert`, each side of a connection verifies the other's certificate against it.
|
|
297
301
|
*
|
|
298
302
|
* @public
|
|
299
303
|
*/
|
|
@@ -342,12 +346,21 @@ declare class GrpcReplicationTransport implements ReplicationTransport {
|
|
|
342
346
|
syncCompleteHandler: SyncCompleteHandler | null;
|
|
343
347
|
/** @internal */
|
|
344
348
|
syncAckHandler: SyncAckHandler | null;
|
|
349
|
+
private runtime;
|
|
345
350
|
constructor(options?: GrpcReplicationOptions);
|
|
346
|
-
/**
|
|
351
|
+
/**
|
|
352
|
+
* Returns the port that the gRPC server listens on, including the port that the operating system picks when `port`
|
|
353
|
+
* is 0, and 0 while no server is listening.
|
|
354
|
+
*/
|
|
347
355
|
getPort(): number;
|
|
348
|
-
/**
|
|
356
|
+
/**
|
|
357
|
+
* Loads the gRPC packages, starts the gRPC server when this node is the primary or has a group ID, and dials every
|
|
358
|
+
* configured endpoint.
|
|
359
|
+
*
|
|
360
|
+
* @throws A `SirannonError` with code `TRANSPORT_DEPENDENCY_MISSING` when this process cannot load `@grpc/grpc-js`, `@bufbuild/protobuf`, or `grpc-health-check`.
|
|
361
|
+
*/
|
|
349
362
|
connect(localNodeId: string, config: TransportConfig): Promise<void>;
|
|
350
|
-
/** Closes every peer connection. */
|
|
363
|
+
/** Closes every peer connection and shuts down the gRPC server. */
|
|
351
364
|
disconnect(): Promise<void>;
|
|
352
365
|
/** Sends one batch of changes to one peer. */
|
|
353
366
|
send(peerId: string, batch: ReplicationBatch): Promise<void>;
|
|
@@ -361,15 +374,15 @@ declare class GrpcReplicationTransport implements ReplicationTransport {
|
|
|
361
374
|
requestSync(peerId: string, request: SyncRequest): Promise<void>;
|
|
362
375
|
/** Sends one page of first-sync table data. */
|
|
363
376
|
sendSyncBatch(peerId: string, batch: SyncBatch): Promise<void>;
|
|
364
|
-
/** Tells a joining node that first sync
|
|
377
|
+
/** Tells a joining node that first sync is complete, and sends the manifests that the node checks its copy against. */
|
|
365
378
|
sendSyncComplete(peerId: string, complete: SyncComplete): Promise<void>;
|
|
366
|
-
/**
|
|
379
|
+
/** Tells the source whether this joining node stored one first-sync page. */
|
|
367
380
|
sendSyncAck(peerId: string, ack: SyncAck): Promise<void>;
|
|
368
381
|
/** Registers the handler that applies incoming change batches. */
|
|
369
382
|
onBatchReceived(handler: BatchHandler): void;
|
|
370
383
|
/** Registers the handler that records incoming acknowledgements. */
|
|
371
384
|
onAckReceived(handler: AckHandler): void;
|
|
372
|
-
/** Registers the handler that
|
|
385
|
+
/** Registers the handler that executes a write that a replica forwards. */
|
|
373
386
|
onForwardReceived(handler: ForwardHandler): void;
|
|
374
387
|
/** Registers the handler that serves a first-sync request. */
|
|
375
388
|
onSyncRequested(handler: SyncRequestHandler): void;
|
|
@@ -379,11 +392,11 @@ declare class GrpcReplicationTransport implements ReplicationTransport {
|
|
|
379
392
|
onSyncCompleteReceived(handler: SyncCompleteHandler): void;
|
|
380
393
|
/** Registers the handler that records first-sync page acknowledgements. */
|
|
381
394
|
onSyncAckReceived(handler: SyncAckHandler): void;
|
|
382
|
-
/** Registers the handler that
|
|
395
|
+
/** Registers the handler that the transport calls when a peer connects. */
|
|
383
396
|
onPeerConnected(handler: PeerConnectedHandler): void;
|
|
384
|
-
/** Registers the handler that
|
|
397
|
+
/** Registers the handler that the transport calls when a peer disconnects. */
|
|
385
398
|
onPeerDisconnected(handler: PeerDisconnectedHandler): void;
|
|
386
|
-
/** Returns every connected peer, keyed by
|
|
399
|
+
/** Returns every connected peer, keyed by node ID. */
|
|
387
400
|
peers(): ReadonlyMap<string, NodeInfo>;
|
|
388
401
|
private extractTlsCN;
|
|
389
402
|
/** @internal */
|