@google-cloud/spanner 7.14.0 → 7.16.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/CHANGELOG.md +36 -0
- package/README.md +14 -2
- package/build/protos/google/spanner/admin/instance/v1/common.proto +7 -0
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +139 -16
- package/build/protos/google/spanner/v1/commit_response.proto +9 -0
- package/build/protos/google/spanner/v1/result_set.proto +21 -0
- package/build/protos/google/spanner/v1/spanner.proto +39 -2
- package/build/protos/google/spanner/v1/transaction.proto +34 -0
- package/build/protos/google/spanner/v1/type.proto +43 -30
- package/build/protos/protos.d.ts +1908 -1452
- package/build/protos/protos.js +5095 -3724
- package/build/protos/protos.json +310 -129
- package/build/src/batch-transaction.d.ts +1 -0
- package/build/src/batch-transaction.js +90 -50
- package/build/src/database.d.ts +6 -2
- package/build/src/database.js +433 -235
- package/build/src/index.d.ts +5 -0
- package/build/src/index.js +4 -0
- package/build/src/instance.d.ts +2 -0
- package/build/src/instance.js +6 -1
- package/build/src/instrument.d.ts +84 -0
- package/build/src/instrument.js +212 -0
- package/build/src/session-pool.d.ts +2 -0
- package/build/src/session-pool.js +61 -23
- package/build/src/session.js +1 -7
- package/build/src/table.d.ts +3 -0
- package/build/src/table.js +34 -14
- package/build/src/transaction.d.ts +3 -0
- package/build/src/transaction.js +411 -194
- package/build/src/v1/spanner_client.d.ts +14 -0
- package/package.json +12 -3
package/build/src/table.js
CHANGED
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.Table = void 0;
|
|
19
19
|
const promisify_1 = require("@google-cloud/promisify");
|
|
20
20
|
const through = require("through2");
|
|
21
|
+
const instrument_1 = require("./instrument");
|
|
21
22
|
const GOOGLE_STANDARD_SQL = 'GOOGLE_STANDARD_SQL';
|
|
22
23
|
const POSTGRESQL = 'POSTGRESQL';
|
|
23
24
|
/**
|
|
@@ -53,12 +54,16 @@ class Table {
|
|
|
53
54
|
* @type {string}
|
|
54
55
|
*/
|
|
55
56
|
this.name = name;
|
|
57
|
+
this._observabilityOptions = database._observabilityOptions;
|
|
56
58
|
}
|
|
57
59
|
create(schema, gaxOptionsOrCallback, cb) {
|
|
58
60
|
const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
|
|
59
61
|
const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
|
|
60
62
|
this.database.createTable(schema, gaxOptions, callback);
|
|
61
63
|
}
|
|
64
|
+
getDBName() {
|
|
65
|
+
return this.database.formattedName_;
|
|
66
|
+
}
|
|
62
67
|
/**
|
|
63
68
|
* Create a readable object stream to receive rows from the database using key
|
|
64
69
|
* lookups and scans.
|
|
@@ -228,20 +233,35 @@ class Table {
|
|
|
228
233
|
* @param {function} callback The callback function.
|
|
229
234
|
*/
|
|
230
235
|
_mutate(method, rows, options = {}, callback) {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
236
|
+
const traceConfig = {
|
|
237
|
+
opts: this._observabilityOptions,
|
|
238
|
+
tableName: this.name,
|
|
239
|
+
dbName: this.getDBName(),
|
|
240
|
+
};
|
|
241
|
+
(0, instrument_1.startTrace)('Table.' + method, traceConfig, span => {
|
|
242
|
+
const requestOptions = 'requestOptions' in options ? options.requestOptions : {};
|
|
243
|
+
const excludeTxnFromChangeStreams = 'excludeTxnFromChangeStreams' in options
|
|
244
|
+
? options.excludeTxnFromChangeStreams
|
|
245
|
+
: false;
|
|
246
|
+
this.database.runTransaction({
|
|
247
|
+
requestOptions: requestOptions,
|
|
248
|
+
excludeTxnFromChangeStreams: excludeTxnFromChangeStreams,
|
|
249
|
+
}, (err, transaction) => {
|
|
250
|
+
if (err) {
|
|
251
|
+
(0, instrument_1.setSpanError)(span, err);
|
|
252
|
+
span.end();
|
|
253
|
+
callback(err);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
transaction[method](this.name, rows);
|
|
257
|
+
transaction.commit(options, (err, resp) => {
|
|
258
|
+
if (err) {
|
|
259
|
+
(0, instrument_1.setSpanError)(span, err);
|
|
260
|
+
}
|
|
261
|
+
span.end();
|
|
262
|
+
callback(err, resp);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
245
265
|
});
|
|
246
266
|
}
|
|
247
267
|
}
|
|
@@ -29,6 +29,7 @@ import { google } from '../protos/protos';
|
|
|
29
29
|
import IQueryOptions = google.spanner.v1.ExecuteSqlRequest.IQueryOptions;
|
|
30
30
|
import IRequestOptions = google.spanner.v1.IRequestOptions;
|
|
31
31
|
import { Spanner } from '.';
|
|
32
|
+
import { ObservabilityOptions } from './instrument';
|
|
32
33
|
export type Rows = Array<Row | Json>;
|
|
33
34
|
export interface TimestampBounds {
|
|
34
35
|
strong?: boolean;
|
|
@@ -241,6 +242,8 @@ export declare class Snapshot extends EventEmitter {
|
|
|
241
242
|
[k: string]: string;
|
|
242
243
|
};
|
|
243
244
|
requestOptions?: Pick<IRequestOptions, 'transactionTag'>;
|
|
245
|
+
_observabilityOptions?: ObservabilityOptions;
|
|
246
|
+
protected _dbName?: string;
|
|
244
247
|
/**
|
|
245
248
|
* The transaction ID.
|
|
246
249
|
*
|