@google-cloud/spanner 7.19.1 → 7.20.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/build/protos/protos.d.ts +0 -144
- package/build/protos/protos.js +48 -288
- package/build/protos/protos.json +3 -0
- package/build/src/batch-transaction.js +5 -3
- package/build/src/codec.d.ts +85 -0
- package/build/src/codec.js +244 -1
- package/build/src/database.d.ts +14 -2
- package/build/src/database.js +35 -25
- package/build/src/index.d.ts +22 -2
- package/build/src/index.js +74 -2
- package/build/src/instance.js +4 -0
- package/build/src/request_id_header.d.ts +4 -1
- package/build/src/request_id_header.js +21 -1
- package/build/src/session-factory.d.ts +24 -2
- package/build/src/session-factory.js +27 -3
- package/build/src/session.d.ts +1 -0
- package/build/src/session.js +11 -3
- package/build/src/table.d.ts +3 -0
- package/build/src/table.js +6 -0
- package/build/src/transaction-runner.d.ts +2 -0
- package/build/src/transaction-runner.js +7 -7
- package/build/src/transaction.d.ts +2 -0
- package/build/src/transaction.js +35 -5
- package/package.json +1 -1
- package/CHANGELOG.md +0 -1611
package/build/src/transaction.js
CHANGED
|
@@ -29,8 +29,10 @@ const instrument_1 = require("./instrument");
|
|
|
29
29
|
const protos_1 = require("../protos/protos");
|
|
30
30
|
const common_1 = require("./common");
|
|
31
31
|
const protos_2 = require("../protos/protos");
|
|
32
|
+
var IsolationLevel = protos_2.google.spanner.v1.TransactionOptions.IsolationLevel;
|
|
32
33
|
var ReadLockMode = protos_2.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode;
|
|
33
34
|
const instrument_2 = require("./instrument");
|
|
35
|
+
const request_id_header_1 = require("./request_id_header");
|
|
34
36
|
const RETRY_INFO_TYPE = 'type.googleapis.com/google.rpc.retryinfo';
|
|
35
37
|
const RETRY_INFO_BIN = 'google.rpc.retryinfo-bin';
|
|
36
38
|
/**
|
|
@@ -182,7 +184,7 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
182
184
|
method: 'beginTransaction',
|
|
183
185
|
reqOpts,
|
|
184
186
|
gaxOpts,
|
|
185
|
-
headers: headers,
|
|
187
|
+
headers: (0, request_id_header_1.injectRequestIDIntoHeaders)(headers, this.session),
|
|
186
188
|
}, (err, resp) => {
|
|
187
189
|
if (err) {
|
|
188
190
|
(0, instrument_2.setSpanError)(span, err);
|
|
@@ -412,6 +414,8 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
412
414
|
return (0, instrument_2.startTrace)('Snapshot.createReadStream', traceConfig, span => {
|
|
413
415
|
var _a;
|
|
414
416
|
let attempt = 0;
|
|
417
|
+
const database = this.session.parent;
|
|
418
|
+
const nthRequest = (0, request_id_header_1.nextNthRequest)(database);
|
|
415
419
|
const makeRequest = (resumeToken) => {
|
|
416
420
|
if (this.id && transaction.begin) {
|
|
417
421
|
delete transaction.begin;
|
|
@@ -437,7 +441,7 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
437
441
|
method: 'streamingRead',
|
|
438
442
|
reqOpts: Object.assign({}, reqOpts, { resumeToken }),
|
|
439
443
|
gaxOpts: gaxOptions,
|
|
440
|
-
headers: headers,
|
|
444
|
+
headers: (0, request_id_header_1.injectRequestIDIntoHeaders)(headers, this.session, nthRequest, attempt),
|
|
441
445
|
});
|
|
442
446
|
};
|
|
443
447
|
const resultStream = (_a = (0, partial_result_stream_1.partialResultStream)(this._wrapWithIdWaiter(makeRequest), {
|
|
@@ -752,6 +756,8 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
752
756
|
};
|
|
753
757
|
return (0, instrument_2.startTrace)('Snapshot.runStream', traceConfig, span => {
|
|
754
758
|
let attempt = 0;
|
|
759
|
+
const database = this.session.parent;
|
|
760
|
+
const nthRequest = (0, request_id_header_1.nextNthRequest)(database);
|
|
755
761
|
const makeRequest = (resumeToken) => {
|
|
756
762
|
attempt++;
|
|
757
763
|
if (!resumeToken) {
|
|
@@ -785,7 +791,7 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
785
791
|
method: 'executeStreamingSql',
|
|
786
792
|
reqOpts: Object.assign({}, reqOpts, { resumeToken }),
|
|
787
793
|
gaxOpts: gaxOptions,
|
|
788
|
-
headers: headers,
|
|
794
|
+
headers: (0, request_id_header_1.injectRequestIDIntoHeaders)(headers, this.session, nthRequest, attempt),
|
|
789
795
|
});
|
|
790
796
|
};
|
|
791
797
|
const resultStream = (0, partial_result_stream_1.partialResultStream)(this._wrapWithIdWaiter(makeRequest), {
|
|
@@ -1154,6 +1160,7 @@ class Transaction extends Dml {
|
|
|
1154
1160
|
super(session, undefined, queryOptions);
|
|
1155
1161
|
this._queuedMutations = [];
|
|
1156
1162
|
this._options = { readWrite: options };
|
|
1163
|
+
this._options.isolationLevel = IsolationLevel.ISOLATION_LEVEL_UNSPECIFIED;
|
|
1157
1164
|
this.requestOptions = requestOptions;
|
|
1158
1165
|
}
|
|
1159
1166
|
batchUpdate(queries, optionsOrCallback, cb) {
|
|
@@ -1195,7 +1202,8 @@ class Transaction extends Dml {
|
|
|
1195
1202
|
seqno: this._seqno++,
|
|
1196
1203
|
statements,
|
|
1197
1204
|
};
|
|
1198
|
-
const
|
|
1205
|
+
const database = this.session.parent;
|
|
1206
|
+
const headers = (0, request_id_header_1.injectRequestIDIntoHeaders)(this.commonHeaders_, this.session, (0, request_id_header_1.nextNthRequest)(database), 1);
|
|
1199
1207
|
if (this._getSpanner().routeToLeaderEnabled) {
|
|
1200
1208
|
(0, common_1.addLeaderAwareRoutingHeader)(headers);
|
|
1201
1209
|
}
|
|
@@ -1317,12 +1325,13 @@ class Transaction extends Dml {
|
|
|
1317
1325
|
(0, common_1.addLeaderAwareRoutingHeader)(headers);
|
|
1318
1326
|
}
|
|
1319
1327
|
span.addEvent('Starting Commit');
|
|
1328
|
+
const database = this.session.parent;
|
|
1320
1329
|
this.request({
|
|
1321
1330
|
client: 'SpannerClient',
|
|
1322
1331
|
method: 'commit',
|
|
1323
1332
|
reqOpts,
|
|
1324
1333
|
gaxOpts: gaxOpts,
|
|
1325
|
-
headers: headers,
|
|
1334
|
+
headers: (0, request_id_header_1.injectRequestIDIntoHeaders)(headers, this.session, (0, request_id_header_1.nextNthRequest)(database), 1),
|
|
1326
1335
|
}, (err, resp) => {
|
|
1327
1336
|
this.end();
|
|
1328
1337
|
if (err) {
|
|
@@ -1736,6 +1745,27 @@ class Transaction extends Dml {
|
|
|
1736
1745
|
excludeTxnFromChangeStreams() {
|
|
1737
1746
|
this._options.excludeTxnFromChangeStreams = true;
|
|
1738
1747
|
}
|
|
1748
|
+
setReadWriteTransactionOptions(options) {
|
|
1749
|
+
/**
|
|
1750
|
+
* Set optimistic concurrency control for the transaction.
|
|
1751
|
+
*/
|
|
1752
|
+
if (options === null || options === void 0 ? void 0 : options.optimisticLock) {
|
|
1753
|
+
this._options.readWrite.readLockMode = ReadLockMode.OPTIMISTIC;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Set option excludeTxnFromChangeStreams=true to exclude read/write transactions
|
|
1757
|
+
* from being tracked in change streams.
|
|
1758
|
+
*/
|
|
1759
|
+
if (options === null || options === void 0 ? void 0 : options.excludeTxnFromChangeStreams) {
|
|
1760
|
+
this._options.excludeTxnFromChangeStreams = true;
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Set isolation level .
|
|
1764
|
+
*/
|
|
1765
|
+
this._options.isolationLevel = (options === null || options === void 0 ? void 0 : options.isolationLevel)
|
|
1766
|
+
? options === null || options === void 0 ? void 0 : options.isolationLevel
|
|
1767
|
+
: this._getSpanner().defaultTransactionOptions.isolationLevel;
|
|
1768
|
+
}
|
|
1739
1769
|
}
|
|
1740
1770
|
exports.Transaction = Transaction;
|
|
1741
1771
|
/*! Developer Documentation
|