camusdb 0.6.0 → 0.7.0
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 +193 -0
- package/dist/client.d.ts +42 -37
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +117 -166
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -1
- package/dist/endpoint-pool.d.ts +8 -0
- package/dist/endpoint-pool.d.ts.map +1 -1
- package/dist/endpoint-pool.js +25 -0
- package/dist/endpoint-pool.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/node-stats.d.ts +113 -0
- package/dist/node-stats.d.ts.map +1 -0
- package/dist/node-stats.js +90 -0
- package/dist/node-stats.js.map +1 -0
- package/dist/options.d.ts +10 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +1 -0
- package/dist/options.js.map +1 -1
- package/dist/pipeline.d.ts +126 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +363 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/prepared/auto-prepare.d.ts +51 -0
- package/dist/prepared/auto-prepare.d.ts.map +1 -0
- package/dist/prepared/auto-prepare.js +150 -0
- package/dist/prepared/auto-prepare.js.map +1 -0
- package/dist/prepared/policy.d.ts +7 -0
- package/dist/prepared/policy.d.ts.map +1 -1
- package/dist/prepared/policy.js +16 -0
- package/dist/prepared/policy.js.map +1 -1
- package/dist/query-stream.d.ts +4 -1
- package/dist/query-stream.d.ts.map +1 -1
- package/dist/query-stream.js +13 -2
- package/dist/query-stream.js.map +1 -1
- package/dist/retry.d.ts +8 -0
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +12 -1
- package/dist/retry.js.map +1 -1
- package/dist/telemetry.d.ts +199 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +422 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/transaction.d.ts +60 -5
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +124 -24
- package/dist/transaction.js.map +1 -1
- package/dist/transport/authenticating-transport.d.ts +9 -1
- package/dist/transport/authenticating-transport.d.ts.map +1 -1
- package/dist/transport/authenticating-transport.js +13 -0
- package/dist/transport/authenticating-transport.js.map +1 -1
- package/dist/transport/grpc/batch-frames.d.ts +23 -5
- package/dist/transport/grpc/batch-frames.d.ts.map +1 -1
- package/dist/transport/grpc/batch-frames.js +29 -8
- package/dist/transport/grpc/batch-frames.js.map +1 -1
- package/dist/transport/grpc/batcher.d.ts +69 -5
- package/dist/transport/grpc/batcher.d.ts.map +1 -1
- package/dist/transport/grpc/batcher.js +217 -10
- package/dist/transport/grpc/batcher.js.map +1 -1
- package/dist/transport/grpc/grpc-transport.d.ts +35 -1
- package/dist/transport/grpc/grpc-transport.d.ts.map +1 -1
- package/dist/transport/grpc/grpc-transport.js +193 -7
- package/dist/transport/grpc/grpc-transport.js.map +1 -1
- package/dist/transport/grpc/messages.d.ts +15 -0
- package/dist/transport/grpc/messages.d.ts.map +1 -1
- package/dist/transport/grpc/messages.js +9 -0
- package/dist/transport/grpc/messages.js.map +1 -1
- package/dist/transport/rest-transport.d.ts +9 -1
- package/dist/transport/rest-transport.d.ts.map +1 -1
- package/dist/transport/rest-transport.js +24 -0
- package/dist/transport/rest-transport.js.map +1 -1
- package/dist/transport/sequential-pipeline.d.ts +21 -0
- package/dist/transport/sequential-pipeline.d.ts.map +1 -0
- package/dist/transport/sequential-pipeline.js +119 -0
- package/dist/transport/sequential-pipeline.js.map +1 -0
- package/dist/transport/transport.d.ts +94 -0
- package/dist/transport/transport.d.ts.map +1 -1
- package/dist/transport/transport.js +10 -0
- package/dist/transport/transport.js.map +1 -1
- package/package.json +10 -4
- package/proto/camus_sql.proto +114 -0
package/dist/transaction.js
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { CamusError } from './errors.js';
|
|
8
8
|
import { CamusErrorCode } from './error-codes.js';
|
|
9
|
+
import { CamusPipeline } from './pipeline.js';
|
|
9
10
|
import { delay } from './retry.js';
|
|
10
11
|
import { CamusRouteOpKind } from './routing/route-cache.js';
|
|
12
|
+
import { CamusRetryKind, recordRetry, traced } from './telemetry.js';
|
|
11
13
|
/**
|
|
12
14
|
* A set of reads and writes that take effect atomically, at one logical instant, across columns,
|
|
13
15
|
* rows, and tables.
|
|
@@ -20,9 +22,13 @@ import { CamusRouteOpKind } from './routing/route-cache.js';
|
|
|
20
22
|
* a later transaction, but never relocates this one. A caller that knows the transaction's hot
|
|
21
23
|
* statement can choose the endpoint at `BEGIN` with `options.affinity` instead.
|
|
22
24
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
25
|
+
* `options.deferBegin` defers `BEGIN` with learned routing off too. The first statement then starts
|
|
26
|
+
* the transaction on the pool's rotation. When that first statement is a `CamusPipeline` send, the
|
|
27
|
+
* `BEGIN` travels inside the same exchange.
|
|
28
|
+
*
|
|
29
|
+
* Two consequences of the deferral are visible, and only for a deferred transaction: the
|
|
30
|
+
* server-minted identity reads as zero until the first statement, and a failure to begin surfaces
|
|
31
|
+
* from that first statement rather than from the call that created the transaction.
|
|
26
32
|
*/
|
|
27
33
|
export class CamusTransaction {
|
|
28
34
|
runtime;
|
|
@@ -39,6 +45,11 @@ export class CamusTransaction {
|
|
|
39
45
|
startPromise;
|
|
40
46
|
startFailed = false;
|
|
41
47
|
finalized = false;
|
|
48
|
+
/**
|
|
49
|
+
* True once a pipeline committed this transaction, so that a later finalize does not ask the
|
|
50
|
+
* server about a transaction it no longer knows.
|
|
51
|
+
*/
|
|
52
|
+
committedByPipeline = false;
|
|
42
53
|
/** The concurrency knobs this transaction was begun with, after every default was applied. */
|
|
43
54
|
options;
|
|
44
55
|
/**
|
|
@@ -61,8 +72,8 @@ export class CamusTransaction {
|
|
|
61
72
|
/**
|
|
62
73
|
* True once the server minted this transaction.
|
|
63
74
|
*
|
|
64
|
-
* It is always true with learned routing off
|
|
65
|
-
* statement, or until an explicit `affinity`, starts it.
|
|
75
|
+
* It is always true with learned routing off and no `deferBegin`. For a deferred transaction it
|
|
76
|
+
* is false until the first statement, or until an explicit `affinity`, starts it.
|
|
66
77
|
*/
|
|
67
78
|
get isStarted() {
|
|
68
79
|
return this.startedValue;
|
|
@@ -106,18 +117,88 @@ export class CamusTransaction {
|
|
|
106
117
|
}
|
|
107
118
|
async startOn(target, signal) {
|
|
108
119
|
try {
|
|
109
|
-
const result = await
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
this.startedValue = true;
|
|
120
|
+
const result = await traced(this.runtime, { operationName: 'BEGIN' }, (operation) => {
|
|
121
|
+
operation?.setEndpoint(target);
|
|
122
|
+
return this.runtime.transport.startTransaction(target, this.runtime.database, this.options, this.runtime.timeoutSeconds, signal);
|
|
123
|
+
});
|
|
124
|
+
this.seat(result, target);
|
|
115
125
|
}
|
|
116
126
|
catch (error) {
|
|
117
127
|
this.startFailed = true;
|
|
118
128
|
throw error;
|
|
119
129
|
}
|
|
120
130
|
}
|
|
131
|
+
seat(result, target) {
|
|
132
|
+
this.txnIdPTValue = result.txnIdPT;
|
|
133
|
+
this.txnIdCounterValue = result.txnIdCounter;
|
|
134
|
+
this.streamSlot = result.streamSlot;
|
|
135
|
+
this.endpointValue = target;
|
|
136
|
+
this.startedValue = true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Several statements of this transaction, sent as one exchange and answered together. See
|
|
140
|
+
* `CamusPipeline`. A transaction begun with `deferBegin`, or with learned routing on, sends its
|
|
141
|
+
* `BEGIN` inside the first pipeline send too.
|
|
142
|
+
*/
|
|
143
|
+
pipeline() {
|
|
144
|
+
return new CamusPipeline(this, this.runtime);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Lets a pipeline begin this transaction inside its first exchange.
|
|
148
|
+
*
|
|
149
|
+
* When nothing has begun the transaction yet, it reports a claim. The pipeline settles the claim
|
|
150
|
+
* after the server answered the `BEGIN`. When a `BEGIN` is already under way, it reports that
|
|
151
|
+
* `BEGIN` for the pipeline to await instead. When the transaction has started, it reports
|
|
152
|
+
* neither. The memoized `startPromise` is what makes a pipeline and a statement that race to be
|
|
153
|
+
* the first one agree on one `BEGIN`.
|
|
154
|
+
*
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
claimStart() {
|
|
158
|
+
if (this.startedValue)
|
|
159
|
+
return {};
|
|
160
|
+
if (this.startPromise !== undefined)
|
|
161
|
+
return { pending: this.startPromise };
|
|
162
|
+
let resolve;
|
|
163
|
+
let reject;
|
|
164
|
+
const promise = new Promise((done, fail) => {
|
|
165
|
+
resolve = done;
|
|
166
|
+
reject = fail;
|
|
167
|
+
});
|
|
168
|
+
// A claim that fails with no statement waiting on it must not be reported as unhandled. The
|
|
169
|
+
// failure reaches the pipeline's caller from the send.
|
|
170
|
+
promise.catch(() => undefined);
|
|
171
|
+
this.startPromise = promise;
|
|
172
|
+
return {
|
|
173
|
+
claim: {
|
|
174
|
+
resolve: (result, target) => {
|
|
175
|
+
this.seat(result, target);
|
|
176
|
+
resolve();
|
|
177
|
+
},
|
|
178
|
+
reject: (error) => {
|
|
179
|
+
this.startFailed = true;
|
|
180
|
+
reject(error);
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Records that a pipeline's conditional commit committed this transaction.
|
|
187
|
+
*
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
190
|
+
markCommittedByPipeline() {
|
|
191
|
+
this.committedByPipeline = true;
|
|
192
|
+
this.finalized = true;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* True when a pipeline committed this transaction.
|
|
196
|
+
*
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
get isCommittedByPipeline() {
|
|
200
|
+
return this.committedByPipeline;
|
|
201
|
+
}
|
|
121
202
|
/** Makes this transaction's writes durable. */
|
|
122
203
|
commit(signal) {
|
|
123
204
|
return this.finalize(true, signal);
|
|
@@ -138,6 +219,15 @@ export class CamusTransaction {
|
|
|
138
219
|
* the server sees the same `BEGIN` and finalize pair it always did.
|
|
139
220
|
*/
|
|
140
221
|
async finalize(commit, signal) {
|
|
222
|
+
// A pipeline committed this transaction already. A rollback has nothing to undo. A second
|
|
223
|
+
// commit is a mistake of the caller, and the server would only answer that it does not know
|
|
224
|
+
// the transaction.
|
|
225
|
+
if (this.committedByPipeline) {
|
|
226
|
+
if (commit) {
|
|
227
|
+
throw new CamusError(CamusErrorCode.Generic, 'A pipeline already committed this transaction.');
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
141
231
|
if (this.finalized) {
|
|
142
232
|
throw new CamusError(CamusErrorCode.Generic, 'This transaction was already committed or rolled back.');
|
|
143
233
|
}
|
|
@@ -149,21 +239,31 @@ export class CamusTransaction {
|
|
|
149
239
|
return;
|
|
150
240
|
}
|
|
151
241
|
const target = await this.ensureStarted(undefined, signal);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
242
|
+
const name = commit ? 'COMMIT' : 'ROLLBACK';
|
|
243
|
+
// One span over every attempt. Each retry is a `camusdb.retry` event on it.
|
|
244
|
+
await traced(this.runtime, { operationName: name }, async (operation) => {
|
|
245
|
+
operation?.setEndpoint(target);
|
|
246
|
+
for (let attempt = 0;; attempt++) {
|
|
247
|
+
try {
|
|
248
|
+
await this.runtime.transport.finalizeTransaction(commit, target, this.runtime.database, this.txnIdPTValue, this.txnIdCounterValue, this.streamSlot, this.runtime.timeoutSeconds, signal);
|
|
249
|
+
this.finalized = true;
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
if (!CamusError.is(error) ||
|
|
254
|
+
error.code !== CamusErrorCode.FinalizeUnresolved ||
|
|
255
|
+
attempt >= MAX_FINALIZE_ATTEMPTS) {
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
recordRetry(CamusRetryKind.Finalize, error, {
|
|
259
|
+
database: this.runtime.database,
|
|
260
|
+
operationName: name,
|
|
261
|
+
operation,
|
|
262
|
+
});
|
|
263
|
+
await delay(finalizeDelayMs(attempt), signal);
|
|
163
264
|
}
|
|
164
|
-
await delay(finalizeDelayMs(attempt), signal);
|
|
165
265
|
}
|
|
166
|
-
}
|
|
266
|
+
});
|
|
167
267
|
}
|
|
168
268
|
/**
|
|
169
269
|
* Rolls the transaction back if it was neither committed nor rolled back, so a `using` block
|
package/dist/transaction.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,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ACH,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAE3B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;QAC3D,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAU,SAAS,GAAG,gBAAgB,CAAC;;AAG/C;;;GAGG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC;;;GAGG;AACH,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { CamusTokenProvider } from '../auth/token-provider.js';
|
|
8
8
|
import type { CamusProtocol } from '../config.js';
|
|
9
|
+
import type { CamusNodeStats } from '../node-stats.js';
|
|
9
10
|
import type { CamusTransactionOptions } from '../options.js';
|
|
10
11
|
import type { CamusRowSource } from '../row-source.js';
|
|
11
|
-
import type { CamusBranchRow, CamusTransport, NonQueryTransportResult, PreparedStatementInfo, QueryTransportResult, StartTransactionResult, TransportInsertRequest, TransportSqlRequest } from './transport.js';
|
|
12
|
+
import type { CamusBranchRow, CamusTransport, NonQueryTransportResult, PipelineTransportResult, PreparedStatementInfo, QueryTransportResult, StartTransactionResult, TransportInsertRequest, TransportPipelineRequest, TransportSqlRequest } from './transport.js';
|
|
12
13
|
/**
|
|
13
14
|
* Wraps a transport with the reactive half of token management.
|
|
14
15
|
*
|
|
@@ -42,6 +43,12 @@ export declare class AuthenticatingTransport implements CamusTransport {
|
|
|
42
43
|
executeQuery(request: TransportSqlRequest): Promise<QueryTransportResult>;
|
|
43
44
|
executeQueryStream(request: TransportSqlRequest): Promise<CamusRowSource>;
|
|
44
45
|
executeNonQuery(request: TransportSqlRequest): Promise<NonQueryTransportResult>;
|
|
46
|
+
/**
|
|
47
|
+
* A pipeline whose `BEGIN` was refused for its token throws and does not report it, so that this
|
|
48
|
+
* replay can happen: none of it ran. A token refused later in the pipeline is reported in the
|
|
49
|
+
* result and not replayed, because the transaction it began is gone either way.
|
|
50
|
+
*/
|
|
51
|
+
executePipeline(request: TransportPipelineRequest): Promise<PipelineTransportResult>;
|
|
45
52
|
insert(request: TransportInsertRequest): Promise<number>;
|
|
46
53
|
executeDdl(request: TransportSqlRequest): Promise<boolean>;
|
|
47
54
|
prepare(endpoint: string, database: string, sql: string, timeoutSeconds: number, signal?: AbortSignal): Promise<PreparedStatementInfo>;
|
|
@@ -51,6 +58,7 @@ export declare class AuthenticatingTransport implements CamusTransport {
|
|
|
51
58
|
*/
|
|
52
59
|
closePrepared(endpoint: string, database: string, sql: string, signal?: AbortSignal): Promise<void>;
|
|
53
60
|
ping(endpoint: string, timeoutSeconds: number, signal?: AbortSignal): Promise<boolean>;
|
|
61
|
+
getNodeStats(endpoint: string, timeoutSeconds: number, signal?: AbortSignal): Promise<CamusNodeStats>;
|
|
54
62
|
createDatabase(endpoint: string, database: string, ifNotExists: boolean, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
55
63
|
createBranchDatabase(endpoint: string, branchName: string, sourceDatabaseName: string, ifNotExists: boolean, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
56
64
|
dropDatabase(endpoint: string, database: string, timeoutSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticating-transport.d.ts","sourceRoot":"","sources":["../../src/transport/authenticating-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"authenticating-transport.d.ts","sourceRoot":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,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,MAAM,EAC1B,WAAW,EAAE,OAAO,EACpB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAahB,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAIhB,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC;IAI5B,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC;IAI5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAIR,GAAG;IAyBjB,OAAO,CAAC,WAAW;CAGpB"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { CamusError } from '../errors.js';
|
|
8
8
|
import { CamusErrorCode } from '../error-codes.js';
|
|
9
|
+
import { CamusRetryKind, recordRetry } from '../telemetry.js';
|
|
9
10
|
/**
|
|
10
11
|
* Wraps a transport with the reactive half of token management.
|
|
11
12
|
*
|
|
@@ -54,6 +55,14 @@ export class AuthenticatingTransport {
|
|
|
54
55
|
executeNonQuery(request) {
|
|
55
56
|
return this.run(() => this.inner.executeNonQuery(request));
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A pipeline whose `BEGIN` was refused for its token throws and does not report it, so that this
|
|
60
|
+
* replay can happen: none of it ran. A token refused later in the pipeline is reported in the
|
|
61
|
+
* result and not replayed, because the transaction it began is gone either way.
|
|
62
|
+
*/
|
|
63
|
+
executePipeline(request) {
|
|
64
|
+
return this.run(() => this.inner.executePipeline(request));
|
|
65
|
+
}
|
|
57
66
|
insert(request) {
|
|
58
67
|
return this.run(() => this.inner.insert(request));
|
|
59
68
|
}
|
|
@@ -73,6 +82,9 @@ export class AuthenticatingTransport {
|
|
|
73
82
|
ping(endpoint, timeoutSeconds, signal) {
|
|
74
83
|
return this.run(() => this.inner.ping(endpoint, timeoutSeconds, signal));
|
|
75
84
|
}
|
|
85
|
+
getNodeStats(endpoint, timeoutSeconds, signal) {
|
|
86
|
+
return this.run(() => this.inner.getNodeStats(endpoint, timeoutSeconds, signal));
|
|
87
|
+
}
|
|
76
88
|
createDatabase(endpoint, database, ifNotExists, timeoutSeconds, signal) {
|
|
77
89
|
return this.run(() => this.inner.createDatabase(endpoint, database, ifNotExists, timeoutSeconds, signal));
|
|
78
90
|
}
|
|
@@ -109,6 +121,7 @@ export class AuthenticatingTransport {
|
|
|
109
121
|
if (presented === undefined)
|
|
110
122
|
throw error;
|
|
111
123
|
this.auth.invalidate(presented);
|
|
124
|
+
recordRetry(CamusRetryKind.TokenRenewal, error);
|
|
112
125
|
}
|
|
113
126
|
return operation();
|
|
114
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticating-transport.js","sourceRoot":"","sources":["../../src/transport/authenticating-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"authenticating-transport.js","sourceRoot":"","sources":["../../src/transport/authenticating-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAc9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,uBAAuB;IAClC,4FAA4F;IACnF,KAAK,CAAiB;IAEd,IAAI,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IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,GAAG,CAAI,SAA2B;QAC9C,+FAA+F;QAC/F,gDAAgD;QAChD,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QAEvC,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YAE1C,2FAA2F;YAC3F,0FAA0F;YAC1F,uFAAuF;YACvF,yFAAyF;YACzF,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;YAErC,IAAI,SAAS,KAAK,SAAS;gBAAE,MAAM,KAAK,CAAC;YAEzC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAChC,WAAW,CAAC,cAAc,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC;IAEO,WAAW,CAAC,KAAc;QAChC,OAAO,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,oBAAoB,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC1G,CAAC;CACF"}
|
|
@@ -33,8 +33,23 @@ export declare const FRAME_HEADER = "camusdb-batch-frames";
|
|
|
33
33
|
* built before frames ignores the header.
|
|
34
34
|
*/
|
|
35
35
|
export declare const FRAME_ACCEPT_HEADER = "camusdb-batch-frames-accept";
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The contract version this client writes, and the highest it reads.
|
|
38
|
+
*
|
|
39
|
+
* Version 1 is frames. Version 2 adds what lets a whole transaction travel in one frame: an item
|
|
40
|
+
* can name the `Start` earlier in its frame (`txnStartRef`) instead of a handle that does not exist
|
|
41
|
+
* yet, and a `CommitIfOk` item commits only when every earlier operation of its transaction
|
|
42
|
+
* succeeded.
|
|
43
|
+
*/
|
|
44
|
+
export declare const FRAME_VERSION = 2;
|
|
45
|
+
/**
|
|
46
|
+
* The lowest announced version on which a pipelined transaction can be written.
|
|
47
|
+
*
|
|
48
|
+
* A server below it ignores `txnStartRef` and runs the operation as an autocommit statement, and
|
|
49
|
+
* it runs `CommitIfOk` as a non-query and leaves the transaction open. So the batcher never writes
|
|
50
|
+
* either one to such a stream, and the transport runs the pipeline one exchange per step instead.
|
|
51
|
+
*/
|
|
52
|
+
export declare const FRAME_PIPELINE_VERSION = 2;
|
|
38
53
|
/** The most operations one frame carries. A server refuses the operations past it. */
|
|
39
54
|
export declare const FRAME_MAX_ITEMS = 256;
|
|
40
55
|
/**
|
|
@@ -46,14 +61,17 @@ export declare const FRAME_MAX_ITEMS = 256;
|
|
|
46
61
|
* own travels as a plain single message.
|
|
47
62
|
*/
|
|
48
63
|
export declare const FRAME_MAX_BYTES: number;
|
|
64
|
+
/** True when a header value announces a contract version that this client can write frames to. */
|
|
65
|
+
export declare function announcesFrames(value: string | undefined): boolean;
|
|
49
66
|
/**
|
|
50
|
-
*
|
|
67
|
+
* The contract version a header value announces, or 0 for no announcement.
|
|
51
68
|
*
|
|
52
69
|
* The whole value must be digits. `Number.parseInt` stops at the first character it cannot read,
|
|
53
70
|
* so it would read `1x` as version 1 and treat a header this client does not understand as an
|
|
54
|
-
* announcement.
|
|
71
|
+
* announcement. A server that announces a version above `FRAME_VERSION` still reads everything
|
|
72
|
+
* this client writes, so the value is kept as announced and not clamped.
|
|
55
73
|
*/
|
|
56
|
-
export declare function
|
|
74
|
+
export declare function announcedFrameVersion(value: string | undefined): number;
|
|
57
75
|
/**
|
|
58
76
|
* An upper bound on the bytes one operation adds to a frame.
|
|
59
77
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-frames.d.ts","sourceRoot":"","sources":["../../../src/transport/grpc/batch-frames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAA6B,MAAM,eAAe,CAAC;AAExF;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,yBAAyB,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"batch-frames.d.ts","sourceRoot":"","sources":["../../../src/transport/grpc/batch-frames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAA6B,MAAM,eAAe,CAAC;AAExF;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,yBAAyB,CAAC;AAEnD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,sFAAsF;AACtF,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,QAAc,CAAC;AAE3C,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAElE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAUvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAElE"}
|
|
@@ -32,8 +32,23 @@ export const FRAME_HEADER = 'camusdb-batch-frames';
|
|
|
32
32
|
* built before frames ignores the header.
|
|
33
33
|
*/
|
|
34
34
|
export const FRAME_ACCEPT_HEADER = 'camusdb-batch-frames-accept';
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The contract version this client writes, and the highest it reads.
|
|
37
|
+
*
|
|
38
|
+
* Version 1 is frames. Version 2 adds what lets a whole transaction travel in one frame: an item
|
|
39
|
+
* can name the `Start` earlier in its frame (`txnStartRef`) instead of a handle that does not exist
|
|
40
|
+
* yet, and a `CommitIfOk` item commits only when every earlier operation of its transaction
|
|
41
|
+
* succeeded.
|
|
42
|
+
*/
|
|
43
|
+
export const FRAME_VERSION = 2;
|
|
44
|
+
/**
|
|
45
|
+
* The lowest announced version on which a pipelined transaction can be written.
|
|
46
|
+
*
|
|
47
|
+
* A server below it ignores `txnStartRef` and runs the operation as an autocommit statement, and
|
|
48
|
+
* it runs `CommitIfOk` as a non-query and leaves the transaction open. So the batcher never writes
|
|
49
|
+
* either one to such a stream, and the transport runs the pipeline one exchange per step instead.
|
|
50
|
+
*/
|
|
51
|
+
export const FRAME_PIPELINE_VERSION = 2;
|
|
37
52
|
/** The most operations one frame carries. A server refuses the operations past it. */
|
|
38
53
|
export const FRAME_MAX_ITEMS = 256;
|
|
39
54
|
/**
|
|
@@ -45,20 +60,26 @@ export const FRAME_MAX_ITEMS = 256;
|
|
|
45
60
|
* own travels as a plain single message.
|
|
46
61
|
*/
|
|
47
62
|
export const FRAME_MAX_BYTES = 1024 * 1024;
|
|
63
|
+
/** True when a header value announces a contract version that this client can write frames to. */
|
|
64
|
+
export function announcesFrames(value) {
|
|
65
|
+
return announcedFrameVersion(value) >= 1;
|
|
66
|
+
}
|
|
48
67
|
/**
|
|
49
|
-
*
|
|
68
|
+
* The contract version a header value announces, or 0 for no announcement.
|
|
50
69
|
*
|
|
51
70
|
* The whole value must be digits. `Number.parseInt` stops at the first character it cannot read,
|
|
52
71
|
* so it would read `1x` as version 1 and treat a header this client does not understand as an
|
|
53
|
-
* announcement.
|
|
72
|
+
* announcement. A server that announces a version above `FRAME_VERSION` still reads everything
|
|
73
|
+
* this client writes, so the value is kept as announced and not clamped.
|
|
54
74
|
*/
|
|
55
|
-
export function
|
|
75
|
+
export function announcedFrameVersion(value) {
|
|
56
76
|
if (value === undefined)
|
|
57
|
-
return
|
|
77
|
+
return 0;
|
|
58
78
|
const text = value.trim();
|
|
59
79
|
if (!/^\d+$/.test(text))
|
|
60
|
-
return
|
|
61
|
-
|
|
80
|
+
return 0;
|
|
81
|
+
const version = Number(text);
|
|
82
|
+
return Number.isSafeInteger(version) && version >= 1 ? version : 0;
|
|
62
83
|
}
|
|
63
84
|
/**
|
|
64
85
|
* An upper bound on the bytes one operation adds to a frame.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-frames.js","sourceRoot":"","sources":["../../../src/transport/grpc/batch-frames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"batch-frames.js","sourceRoot":"","sources":["../../../src/transport/grpc/batch-frames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GA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|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { GrpcBatchOptions } from '../../config.js';
|
|
8
8
|
import type { GrpcBatchExecuteRequest, GrpcBatchExecuteResponse, GrpcResultRow, GrpcResultSchema, GrpcSqlRequest, GrpcTxnHandle } from './messages.js';
|
|
9
|
+
import { GrpcBatchStatementKind } from './messages.js';
|
|
9
10
|
import type { CamusCacheMetadata } from '../../cache.js';
|
|
10
11
|
import type { CamusRoutingAdvice } from '../../routing/advice.js';
|
|
11
12
|
/** The hybrid-logical-clock token a reply carried. All three components are load-bearing. */
|
|
@@ -51,18 +52,40 @@ export declare class PreparedStatementStaleError extends Error {
|
|
|
51
52
|
readonly name = "PreparedStatementStaleError";
|
|
52
53
|
constructor();
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* One operation of a pipeline handed to `enqueuePipeline`, before the batcher gives it a request
|
|
57
|
+
* id. `expectedTransportId` is the stream that a prepared execution's handle lives on, as for a
|
|
58
|
+
* lone operation.
|
|
59
|
+
*/
|
|
60
|
+
export interface PipelineOp {
|
|
61
|
+
readonly kind: GrpcBatchStatementKind;
|
|
62
|
+
readonly request: GrpcSqlRequest;
|
|
63
|
+
readonly expectedTransportId?: number | undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Raised on every operation of a pipeline that the batcher refused to write as one frame, before
|
|
67
|
+
* any of it was written. The causes are a server that announced a contract version below
|
|
68
|
+
* `FRAME_PIPELINE_VERSION`, frames that are off, or a pipeline that does not fit one frame.
|
|
69
|
+
* Nothing ran, so the caller can run the same operations one exchange at a time.
|
|
70
|
+
*/
|
|
71
|
+
export declare class PipelineUnsupportedError extends Error {
|
|
72
|
+
readonly name = "PipelineUnsupportedError";
|
|
73
|
+
readonly reason: string;
|
|
74
|
+
constructor(reason: string);
|
|
75
|
+
}
|
|
54
76
|
/** One `BatchExecute` duplex call, behind an interface a test can substitute for. */
|
|
55
77
|
export interface BatchStream {
|
|
56
78
|
/** Identifies this stream. A handle registered on it is invalid on any other. */
|
|
57
79
|
readonly id: number;
|
|
58
80
|
/**
|
|
59
|
-
*
|
|
81
|
+
* The frame contract version this stream's server announced, or 0 while it announced nothing.
|
|
60
82
|
*
|
|
61
|
-
* It never blocks, and it never goes
|
|
62
|
-
*
|
|
63
|
-
*
|
|
83
|
+
* It never blocks, and it never goes down. It is 0 until the announcement arrives, and it stays
|
|
84
|
+
* 0 against a server that makes none. It belongs to one stream, so a rebuilt stream negotiates
|
|
85
|
+
* again on its own. Version 1 lets the batcher write frames. `FRAME_PIPELINE_VERSION` lets it
|
|
86
|
+
* write a whole transaction as one frame.
|
|
64
87
|
*/
|
|
65
|
-
readonly
|
|
88
|
+
readonly announcedVersion: number;
|
|
66
89
|
send(request: GrpcBatchExecuteRequest): void;
|
|
67
90
|
/** Registers the callbacks that drive the reader loop. Called once, right after construction. */
|
|
68
91
|
listen(handlers: {
|
|
@@ -87,6 +110,13 @@ export interface BatchStream {
|
|
|
87
110
|
* always was. It is a transport optimization alone. It gives no atomicity and no ordering that the
|
|
88
111
|
* stream does not already give.
|
|
89
112
|
*
|
|
113
|
+
* A whole transaction can travel as one frame. `enqueuePipeline` takes the operations of one
|
|
114
|
+
* transaction — a start that its followers name instead of a handle, statements, and a conditional
|
|
115
|
+
* commit — and places them on the inbox together, so they are written as one frame or not at all.
|
|
116
|
+
* The two items that make this possible are contract version 2. A stream whose server announced
|
|
117
|
+
* less gets none of them: the pipeline faults before any byte is written, and the caller runs the
|
|
118
|
+
* same operations one exchange at a time.
|
|
119
|
+
*
|
|
90
120
|
* A stream that faults is rebuilt by the next write, and every operation that was in flight on the
|
|
91
121
|
* old one is failed so its caller can decide whether to replay it. Prepared statements are scoped
|
|
92
122
|
* to the stream that registered them, and a handle from a stream that is gone is refused at the
|
|
@@ -140,6 +170,27 @@ export declare class GrpcBatcher {
|
|
|
140
170
|
enqueueStart(request: GrpcSqlRequest, slotIndex: number, signal: AbortSignal | undefined): Promise<GrpcTxnHandle>;
|
|
141
171
|
enqueueCommit(request: GrpcSqlRequest, slotIndex: number, signal: AbortSignal | undefined): Promise<BatchCausalToken>;
|
|
142
172
|
enqueueRollback(request: GrpcSqlRequest, slotIndex: number, signal: AbortSignal | undefined): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Enqueues the operations of one transaction so that they travel as one frame, in the given
|
|
175
|
+
* order: an optional start at the head, statements, and an optional conditional commit at the
|
|
176
|
+
* end. Every operation after a start names it by `txnStartRef`, because its handle does not
|
|
177
|
+
* exist yet.
|
|
178
|
+
*
|
|
179
|
+
* It returns one promise per operation. Each one settles with that operation's own answer — a
|
|
180
|
+
* `GrpcTxnHandle`, a `BatchQueryResult`, a `BatchNonQueryResult`, or a `BatchCausalToken` — or
|
|
181
|
+
* with its own error, as a lone operation's does.
|
|
182
|
+
*
|
|
183
|
+
* The operations go on the slot's inbox together, so no other operation of the same transaction
|
|
184
|
+
* can come between them. They are written together or not at all. A named start and a
|
|
185
|
+
* conditional commit are contract version 2. So on a stream whose server announced less, with
|
|
186
|
+
* frames off, or when the pipeline does not fit one frame, nothing is written and every promise
|
|
187
|
+
* rejects with `PipelineUnsupportedError`. A pipeline of plain statements on a known handle needs
|
|
188
|
+
* no version, and is staged as those operations would be alone, still in order.
|
|
189
|
+
*
|
|
190
|
+
* One signal covers the whole pipeline. A pipeline with a cancelled member is left out whole,
|
|
191
|
+
* because to write the rest could commit a transaction that is missing one of its statements.
|
|
192
|
+
*/
|
|
193
|
+
enqueuePipeline(ops: readonly PipelineOp[], slotIndex: number, signal: AbortSignal | undefined): Promise<unknown>[];
|
|
143
194
|
/**
|
|
144
195
|
* The registration for a statement on one stream, creating it when there is none.
|
|
145
196
|
*
|
|
@@ -184,6 +235,19 @@ export declare class GrpcBatcher {
|
|
|
184
235
|
* order is the only order the callers gave.
|
|
185
236
|
*/
|
|
186
237
|
private stage;
|
|
238
|
+
/** Writes a routed operation alone, or adds it to the slot's run so it shares the next frame. */
|
|
239
|
+
private place;
|
|
240
|
+
/**
|
|
241
|
+
* Stages a pipeline.
|
|
242
|
+
*
|
|
243
|
+
* The group is routed as one, because its operations are one transaction and so use one stream,
|
|
244
|
+
* and that stream is held for every operation. A group that needs the pipeline contract goes into
|
|
245
|
+
* the slot's run whole. The run is flushed first when it is for another stream or has no room for
|
|
246
|
+
* the whole group. A group that needs no contract version is placed one operation at a time, as
|
|
247
|
+
* lone operations are, still in order. A group that cannot be written as one frame faults whole,
|
|
248
|
+
* before anything is held or written.
|
|
249
|
+
*/
|
|
250
|
+
private stageGroup;
|
|
187
251
|
/**
|
|
188
252
|
* Writes the slot's run: one frame, or the plain single message when one operation is left in
|
|
189
253
|
* it, so a quiet stream stays byte-identical to a stream without frames.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../src/transport/grpc/batcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMxD,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EAExB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"batcher.d.ts","sourceRoot":"","sources":["../../../src/transport/grpc/batcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMxD,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EAExB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,6FAA6F;AAC7F,MAAM,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