@google-cloud/spanner 8.7.0 → 8.8.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.
@@ -29,6 +29,8 @@ const codec_1 = require("./codec");
29
29
  const protos_1 = require("../protos/protos");
30
30
  const stream = require("stream");
31
31
  const helper_1 = require("./helper");
32
+ const originalDecode = codec_1.codec.decode;
33
+ const originalConvertFieldsToJson = codec_1.codec.convertFieldsToJson;
32
34
  /**
33
35
  * The PartialResultStream transforms partial result set objects into Row
34
36
  * objects.
@@ -41,6 +43,7 @@ const helper_1 = require("./helper");
41
43
  class PartialResultStream extends stream_1.Transform {
42
44
  _destroyed;
43
45
  _fields;
46
+ _decoders;
44
47
  _options;
45
48
  _pendingValue;
46
49
  _pendingValueForResume;
@@ -87,10 +90,28 @@ class PartialResultStream extends stream_1.Transform {
87
90
  if (!this._fields && chunk.metadata) {
88
91
  this._fields = chunk.metadata.rowType
89
92
  .fields;
93
+ this._decoders = this._fields.map(({ name, type }) => {
94
+ const columnMetadata = this._options.columnsMetadata &&
95
+ name !== null &&
96
+ name !== undefined &&
97
+ Object.prototype.hasOwnProperty.call(this._options.columnsMetadata, name)
98
+ ? this._options.columnsMetadata[name]
99
+ : undefined;
100
+ if (codec_1.codec.decode !== originalDecode) {
101
+ return val => codec_1.codec.decode(val, type, columnMetadata);
102
+ }
103
+ return codec_1.codec.getDecoder(type, columnMetadata, this._options.json ? this._options.jsonOptions || {} : undefined);
104
+ });
90
105
  }
91
106
  let res = true;
92
107
  if (!(0, helper_1.isEmpty)(chunk.values)) {
93
- res = this._addChunk(chunk);
108
+ try {
109
+ res = this._addChunk(chunk);
110
+ }
111
+ catch (err) {
112
+ next(err);
113
+ return;
114
+ }
94
115
  }
95
116
  if (chunk.last) {
96
117
  this.push(null);
@@ -149,7 +170,12 @@ class PartialResultStream extends stream_1.Transform {
149
170
  * @param {object} chunk The partial result set.
150
171
  */
151
172
  _addChunk(chunk) {
152
- const values = chunk.values.map(service_1.GrpcService.decodeValue_);
173
+ const chunkValues = chunk.values;
174
+ const numValues = chunkValues.length;
175
+ const values = new Array(numValues);
176
+ for (let i = 0; i < numValues; i++) {
177
+ values[i] = service_1.GrpcService.decodeValue_(chunkValues[i]);
178
+ }
153
179
  // If we have a chunk to merge, merge the values now.
154
180
  if (this._pendingValue) {
155
181
  const currentField = this._values.length % this._fields.length;
@@ -170,12 +196,13 @@ class PartialResultStream extends stream_1.Transform {
170
196
  delete this._pendingValueForResume;
171
197
  }
172
198
  let res = true;
173
- values.forEach(value => {
174
- res = this._addValue(value) && res;
199
+ const len = values.length;
200
+ for (let i = 0; i < len; i++) {
201
+ res = this._addValue(values[i]) && res;
175
202
  if (!res) {
176
203
  this.emit('paused');
177
204
  }
178
- });
205
+ }
179
206
  return res;
180
207
  }
181
208
  /**
@@ -193,12 +220,50 @@ class PartialResultStream extends stream_1.Transform {
193
220
  return true;
194
221
  }
195
222
  this._values = [];
223
+ const isJsonStubbed = codec_1.codec.convertFieldsToJson !== originalConvertFieldsToJson;
224
+ if (this._options.json && !isJsonStubbed) {
225
+ return this.push(this._createJsonRow(values));
226
+ }
196
227
  const row = this._createRow(values);
197
228
  if (this._options.json) {
198
229
  return this.push(row.toJSON(this._options.jsonOptions));
199
230
  }
200
231
  return this.push(row);
201
232
  }
233
+ /**
234
+ * Directly creates a plain JSON object from row cell values, bypassing
235
+ * Struct, Row, and WrappedNumber class wrappers when possible.
236
+ *
237
+ * @private
238
+ *
239
+ * @param {Value[]} values The raw cell values for the current row.
240
+ * @returns {Json} The plain JavaScript object representing the row.
241
+ */
242
+ _createJsonRow(values) {
243
+ const json = {};
244
+ const fields = this._fields;
245
+ const decoders = this._decoders;
246
+ const len = fields.length;
247
+ const includeNameless = !!this._options.jsonOptions?.includeNameless;
248
+ for (let i = 0; i < len; i++) {
249
+ const { name } = fields[i];
250
+ if (!name && !includeNameless) {
251
+ continue;
252
+ }
253
+ const fieldName = name ? name : `_${i}`;
254
+ try {
255
+ json[fieldName] = decoders[i](values[i]);
256
+ }
257
+ catch (e) {
258
+ e.message = [
259
+ `Serializing column "${fieldName}" encountered an error: ${e.message}`,
260
+ 'Call row.toJSON({ wrapNumbers: true }) to receive a custom type.',
261
+ ].join(' ');
262
+ throw e;
263
+ }
264
+ }
265
+ return json;
266
+ }
202
267
  /**
203
268
  * Converts an array of values into a row.
204
269
  *
@@ -208,14 +273,16 @@ class PartialResultStream extends stream_1.Transform {
208
273
  * @returns {Row}
209
274
  */
210
275
  _createRow(values) {
211
- const fields = values.map((value, index) => {
212
- const { name, type } = this._fields[index];
213
- const columnMetadata = this._options.columnsMetadata?.[name];
214
- return {
215
- name,
216
- value: codec_1.codec.decode(value, type, columnMetadata),
276
+ const len = values.length;
277
+ const fields = new Array(len);
278
+ const decoders = this._decoders;
279
+ const classFields = this._fields;
280
+ for (let i = 0; i < len; i++) {
281
+ fields[i] = {
282
+ name: classFields[i].name,
283
+ value: decoders[i](values[i]),
217
284
  };
218
- });
285
+ }
219
286
  Object.defineProperty(fields, 'toJSON', {
220
287
  value: (options) => {
221
288
  return codec_1.codec.convertFieldsToJson(fields, options);
@@ -31,6 +31,8 @@ const randIdForProcess = (0, crypto_1.randomBytes)(8)
31
31
  .toString(16)
32
32
  .padStart(8, '0');
33
33
  exports.randIdForProcess = randIdForProcess;
34
+ const REQUEST_HEADER_VERSION = 1;
35
+ const PROCESS_PREFIX = `${REQUEST_HEADER_VERSION}.${randIdForProcess}.`;
34
36
  const X_GOOG_SPANNER_REQUEST_ID_HEADER = 'x-goog-spanner-request-id';
35
37
  exports.X_GOOG_SPANNER_REQUEST_ID_HEADER = X_GOOG_SPANNER_REQUEST_ID_HEADER;
36
38
  class AtomicCounter {
@@ -59,9 +61,8 @@ class AtomicCounter {
59
61
  }
60
62
  }
61
63
  exports.AtomicCounter = AtomicCounter;
62
- const REQUEST_HEADER_VERSION = 1;
63
64
  function craftRequestId(nthClientId, channelId, nthRequest, attempt) {
64
- return `${REQUEST_HEADER_VERSION}.${randIdForProcess}.${nthClientId}.${channelId}.${nthRequest}.${attempt}`;
65
+ return `${PROCESS_PREFIX}${nthClientId}.${channelId}.${nthRequest}.${attempt}`;
65
66
  }
66
67
  const nthClientId = new AtomicCounter();
67
68
  // Only exported for deterministic testing.
@@ -105,38 +106,24 @@ function injectRequestIDIntoHeaders(headers, session, nthRequest, attempt) {
105
106
  if (!session) {
106
107
  return headers;
107
108
  }
109
+ const database = session.parent;
108
110
  if (!nthRequest) {
109
- const database = session.parent;
110
- if (!(database && typeof database._nextNthRequest === 'function')) {
111
+ if (!database || typeof database._nextNthRequest !== 'function') {
111
112
  return headers;
112
113
  }
113
114
  nthRequest = database._nextNthRequest();
114
115
  }
115
- attempt = attempt || 1;
116
- return _metadataWithRequestId(session, nthRequest, attempt, headers);
117
- }
118
- function _metadataWithRequestId(session, nthRequest, attempt, priorMetadata) {
119
- if (!priorMetadata) {
120
- priorMetadata = {};
121
- }
122
- const withReqId = {
123
- ...priorMetadata,
124
- };
125
- const database = session.parent;
126
- let clientId = 1;
127
- let channelId = 1;
128
- if (database) {
129
- clientId = database._nthClientId || 1;
130
- channelId = database._channelId || 1;
131
- }
132
- withReqId[X_GOOG_SPANNER_REQUEST_ID_HEADER] = craftRequestId(clientId, channelId, nthRequest, attempt);
116
+ const clientId = database ? database._nthClientId || 1 : 1;
117
+ const channelId = database ? database._channelId || 1 : 1;
118
+ const withReqId = { ...headers };
119
+ withReqId[X_GOOG_SPANNER_REQUEST_ID_HEADER] = craftRequestId(clientId, channelId, nthRequest || 1, attempt || 1);
133
120
  return withReqId;
134
121
  }
135
122
  function nextNthRequest(database) {
136
- if (!(database && typeof database._nextNthRequest === 'function')) {
137
- return 1;
123
+ if (database && typeof database._nextNthRequest === 'function') {
124
+ return database._nextNthRequest();
138
125
  }
139
- return database._nextNthRequest();
126
+ return 1;
140
127
  }
141
128
  const X_GOOG_SPANNER_REQUEST_ID_SPAN_ATTR = 'x_goog_spanner_request_id';
142
129
  exports.X_GOOG_SPANNER_REQUEST_ID_SPAN_ATTR = X_GOOG_SPANNER_REQUEST_ID_SPAN_ATTR;
@@ -20,6 +20,7 @@ exports.isSessionNotFoundError = isSessionNotFoundError;
20
20
  const events_1 = require("events");
21
21
  const p_queue_1 = require("p-queue");
22
22
  const google_gax_1 = require("google-gax");
23
+ const api_1 = require("@opentelemetry/api");
23
24
  const trace = require("stack-trace");
24
25
  const instrument_1 = require("./instrument");
25
26
  const helper_1 = require("./helper");
@@ -450,40 +451,42 @@ class SessionPool extends events_1.EventEmitter {
450
451
  opts: this._observabilityOptions,
451
452
  dbName: this.database.formattedName_,
452
453
  };
453
- return (0, instrument_1.startTrace)('SessionPool.createSessions', traceConfig, async (span) => {
454
- span.addEvent(`Requesting ${amount} sessions`);
455
- // while we can request as many sessions be created as we want, the backend
456
- // will return at most 100 at a time, hence the need for a while loop.
457
- while (amount > 0) {
458
- let sessions = null;
459
- span.addEvent(`Creating ${amount} sessions`);
460
- try {
461
- [sessions] = await this.database.batchCreateSessions({
462
- count: amount,
463
- labels: labels,
464
- databaseRole: databaseRole,
454
+ return api_1.context.with(api_1.ROOT_CONTEXT, () => {
455
+ return (0, instrument_1.startTrace)('SessionPool.createSessions', traceConfig, async (span) => {
456
+ span.addEvent(`Requesting ${amount} sessions`);
457
+ // while we can request as many sessions be created as we want, the backend
458
+ // will return at most 100 at a time, hence the need for a while loop.
459
+ while (amount > 0) {
460
+ let sessions = null;
461
+ span.addEvent(`Creating ${amount} sessions`);
462
+ try {
463
+ [sessions] = await this.database.batchCreateSessions({
464
+ count: amount,
465
+ labels: labels,
466
+ databaseRole: databaseRole,
467
+ });
468
+ amount -= sessions.length;
469
+ nReturned += sessions.length;
470
+ }
471
+ catch (e) {
472
+ this._pending -= amount;
473
+ this.emit('createError', e);
474
+ span.addEvent(`Requested for ${nRequested} sessions returned ${nReturned}`);
475
+ (0, instrument_1.setSpanErrorAndException)(span, e);
476
+ span.end();
477
+ throw e;
478
+ }
479
+ sessions.forEach((session) => {
480
+ setImmediate(() => {
481
+ this._inventory.borrowed.add(session);
482
+ this._pending -= 1;
483
+ this.release(session);
484
+ });
465
485
  });
466
- amount -= sessions.length;
467
- nReturned += sessions.length;
468
486
  }
469
- catch (e) {
470
- this._pending -= amount;
471
- this.emit('createError', e);
472
- span.addEvent(`Requested for ${nRequested} sessions returned ${nReturned}`);
473
- (0, instrument_1.setSpanErrorAndException)(span, e);
474
- span.end();
475
- throw e;
476
- }
477
- sessions.forEach((session) => {
478
- setImmediate(() => {
479
- this._inventory.borrowed.add(session);
480
- this._pending -= 1;
481
- this.release(session);
482
- });
483
- });
484
- }
485
- span.addEvent(`Requested for ${nRequested} sessions returned ${nReturned}`);
486
- span.end();
487
+ span.addEvent(`Requested for ${nRequested} sessions returned ${nReturned}`);
488
+ span.end();
489
+ });
487
490
  });
488
491
  }
489
492
  /**
@@ -757,10 +760,10 @@ class SessionPool extends events_1.EventEmitter {
757
760
  */
758
761
  _startHouseKeeping() {
759
762
  const evictRate = this.options.idlesAfter * 60000;
760
- this._evictHandle = setInterval(() => this._evictIdleSessions(), evictRate);
763
+ this._evictHandle = api_1.context.with(api_1.ROOT_CONTEXT, () => setInterval(() => this._evictIdleSessions(), evictRate));
761
764
  this._evictHandle.unref();
762
765
  const pingRate = this.options.keepAlive * 60000;
763
- this._pingHandle = setInterval(() => this._pingIdleSessions(), pingRate);
766
+ this._pingHandle = api_1.context.with(api_1.ROOT_CONTEXT, () => setInterval(() => this._pingIdleSessions(), pingRate));
764
767
  this._pingHandle.unref();
765
768
  }
766
769
  /**
@@ -206,7 +206,7 @@ class Session extends common.GrpcServiceObject {
206
206
  },
207
207
  });
208
208
  this._observabilityOptions = database._observabilityOptions;
209
- this.commonHeaders_ = (0, common_1.getCommonHeaders)(this.parent.formattedName_, this._observabilityOptions?.enableEndToEndTracing);
209
+ this.commonHeaders_ = { ...database.commonHeaders_ };
210
210
  this.request = database.request;
211
211
  this.requestStream = database.requestStream;
212
212
  if (name) {
@@ -166,7 +166,7 @@ class Snapshot extends events_1.EventEmitter {
166
166
  this._waitingRequests = [];
167
167
  this._inlineBeginStarted = false;
168
168
  this._observabilityOptions = session._observabilityOptions;
169
- this.commonHeaders_ = (0, common_1.getCommonHeaders)(this._dbName, this._observabilityOptions?.enableEndToEndTracing);
169
+ this.commonHeaders_ = { ...session.commonHeaders_ };
170
170
  this._traceConfig = {
171
171
  opts: this._observabilityOptions,
172
172
  dbName: this._dbName,
@@ -350,7 +350,7 @@ export declare class SpannerClient {
350
350
  * constraints). Given this, successful execution of a DML statement shouldn't
351
351
  * be assumed until a subsequent `Commit` call completes successfully.
352
352
  * @param {google.spanner.v1.RoutingHint} [request.routingHint]
353
- * Optional. If present, it makes the Spanner requests location-aware.
353
+ * Optional. Makes the Spanner requests location-aware if present.
354
354
  *
355
355
  * It gives the server hints that can be used to route the request
356
356
  * to an appropriate server, potentially significantly decreasing latency and
@@ -527,7 +527,7 @@ export declare class SpannerClient {
527
527
  * Optional. Lock Hint for the request, it can only be used with read-write
528
528
  * transactions.
529
529
  * @param {google.spanner.v1.RoutingHint} [request.routingHint]
530
- * Optional. If present, it makes the Spanner requests location-aware.
530
+ * Optional. Makes the Spanner requests location-aware if present.
531
531
  *
532
532
  * It gives the server hints that can be used to route the request
533
533
  * to an appropriate server, potentially significantly decreasing latency and
@@ -571,6 +571,13 @@ export declare class SpannerClient {
571
571
  * that commit mutations but don't perform any reads or queries. You must
572
572
  * randomly select one of the mutations from the mutation set and send it as a
573
573
  * part of this request.
574
+ * @param {google.spanner.v1.RoutingHint} [request.routingHint]
575
+ * Optional. Makes the Spanner requests location-aware if present.
576
+ *
577
+ * It gives the server hints that can be used to route the request
578
+ * to an appropriate server, potentially significantly decreasing latency and
579
+ * improving throughput. To achieve improved performance, most fields must be
580
+ * filled in with accurate values.
574
581
  * @param {object} [options]
575
582
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
576
583
  * @returns {Promise} - The promise which resolves to an array.
@@ -638,6 +645,13 @@ export declare class SpannerClient {
638
645
  * session, then you must include the precommit token with the highest
639
646
  * sequence number received in this transaction attempt. Failing to do so
640
647
  * results in a `FailedPrecondition` error.
648
+ * @param {google.spanner.v1.RoutingHint} [request.routingHint]
649
+ * Optional. Makes the Spanner requests location-aware if present.
650
+ *
651
+ * It gives the server hints that can be used to route the request
652
+ * to an appropriate server, potentially significantly decreasing latency and
653
+ * improving throughput. To achieve improved performance, most fields must be
654
+ * filled in with accurate values.
641
655
  * @param {object} [options]
642
656
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
643
657
  * @returns {Promise} - The promise which resolves to an array.
@@ -924,7 +938,7 @@ export declare class SpannerClient {
924
938
  * constraints). Given this, successful execution of a DML statement shouldn't
925
939
  * be assumed until a subsequent `Commit` call completes successfully.
926
940
  * @param {google.spanner.v1.RoutingHint} [request.routingHint]
927
- * Optional. If present, it makes the Spanner requests location-aware.
941
+ * Optional. Makes the Spanner requests location-aware if present.
928
942
  *
929
943
  * It gives the server hints that can be used to route the request
930
944
  * to an appropriate server, potentially significantly decreasing latency and
@@ -1020,7 +1034,7 @@ export declare class SpannerClient {
1020
1034
  * Optional. Lock Hint for the request, it can only be used with read-write
1021
1035
  * transactions.
1022
1036
  * @param {google.spanner.v1.RoutingHint} [request.routingHint]
1023
- * Optional. If present, it makes the Spanner requests location-aware.
1037
+ * Optional. Makes the Spanner requests location-aware if present.
1024
1038
  *
1025
1039
  * It gives the server hints that can be used to route the request
1026
1040
  * to an appropriate server, potentially significantly decreasing latency and
@@ -1071,6 +1085,35 @@ export declare class SpannerClient {
1071
1085
  * for more details and examples.
1072
1086
  */
1073
1087
  batchWrite(request?: protos.google.spanner.v1.IBatchWriteRequest, options?: CallOptions): gax.CancellableStream;
1088
+ /**
1089
+ * Retrieves a cache update for a given database.
1090
+ *
1091
+ * This RPC can be used to warm up the client cache by fetching key recipes
1092
+ * and server information for a given database. It is recommended to call
1093
+ * this RPC at the beginning of the client's lifecycle, prior to any other
1094
+ * data plane operations.
1095
+ *
1096
+ * The cache update is returned as a stream because the response can be too
1097
+ * large to fit into a single `CacheUpdate` message.
1098
+ *
1099
+ * @param {Object} request
1100
+ * The request object that will be sent.
1101
+ * @param {string} request.database
1102
+ * Required. The database for which to retrieve the cache update.
1103
+ * @param {number} [request.maxRecipeCount]
1104
+ * Optional. The maximum number of key recipes to return in the response.
1105
+ * If not set, a default limit of 100 will be used.
1106
+ * @param {number} [request.maxRangeCount]
1107
+ * Optional. The maximum number of ranges to return in the response.
1108
+ * If not set, a default limit of 10000 will be used.
1109
+ * @param {object} [options]
1110
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1111
+ * @returns {Stream}
1112
+ * An object stream which emits {@link protos.google.spanner.v1.CacheUpdate|CacheUpdate} on 'data' event.
1113
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
1114
+ * for more details and examples.
1115
+ */
1116
+ fetchCacheUpdate(request?: protos.google.spanner.v1.IFetchCacheUpdateRequest, options?: CallOptions): gax.CancellableStream;
1074
1117
  /**
1075
1118
  * Lists all sessions in a given database.
1076
1119
  *
@@ -185,6 +185,7 @@ class SpannerClient {
185
185
  executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
186
186
  streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
187
187
  batchWrite: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
188
+ fetchCacheUpdate: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
188
189
  };
189
190
  // Put together the default options sent with requests.
190
191
  this._defaults = this._gaxGrpc.constructSettings('google.spanner.v1.Spanner', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -236,6 +237,7 @@ class SpannerClient {
236
237
  'partitionQuery',
237
238
  'partitionRead',
238
239
  'batchWrite',
240
+ 'fetchCacheUpdate',
239
241
  ];
240
242
  for (const methodName of spannerStubMethods) {
241
243
  const callPromise = this.spannerStub.then(stub => (...args) => {
@@ -945,7 +947,7 @@ class SpannerClient {
945
947
  * constraints). Given this, successful execution of a DML statement shouldn't
946
948
  * be assumed until a subsequent `Commit` call completes successfully.
947
949
  * @param {google.spanner.v1.RoutingHint} [request.routingHint]
948
- * Optional. If present, it makes the Spanner requests location-aware.
950
+ * Optional. Makes the Spanner requests location-aware if present.
949
951
  *
950
952
  * It gives the server hints that can be used to route the request
951
953
  * to an appropriate server, potentially significantly decreasing latency and
@@ -1055,7 +1057,7 @@ class SpannerClient {
1055
1057
  * Optional. Lock Hint for the request, it can only be used with read-write
1056
1058
  * transactions.
1057
1059
  * @param {google.spanner.v1.RoutingHint} [request.routingHint]
1058
- * Optional. If present, it makes the Spanner requests location-aware.
1060
+ * Optional. Makes the Spanner requests location-aware if present.
1059
1061
  *
1060
1062
  * It gives the server hints that can be used to route the request
1061
1063
  * to an appropriate server, potentially significantly decreasing latency and
@@ -1134,6 +1136,49 @@ class SpannerClient {
1134
1136
  this._log.info('batchWrite stream %j', options);
1135
1137
  return this.innerApiCalls.batchWrite(request, options);
1136
1138
  }
1139
+ /**
1140
+ * Retrieves a cache update for a given database.
1141
+ *
1142
+ * This RPC can be used to warm up the client cache by fetching key recipes
1143
+ * and server information for a given database. It is recommended to call
1144
+ * this RPC at the beginning of the client's lifecycle, prior to any other
1145
+ * data plane operations.
1146
+ *
1147
+ * The cache update is returned as a stream because the response can be too
1148
+ * large to fit into a single `CacheUpdate` message.
1149
+ *
1150
+ * @param {Object} request
1151
+ * The request object that will be sent.
1152
+ * @param {string} request.database
1153
+ * Required. The database for which to retrieve the cache update.
1154
+ * @param {number} [request.maxRecipeCount]
1155
+ * Optional. The maximum number of key recipes to return in the response.
1156
+ * If not set, a default limit of 100 will be used.
1157
+ * @param {number} [request.maxRangeCount]
1158
+ * Optional. The maximum number of ranges to return in the response.
1159
+ * If not set, a default limit of 10000 will be used.
1160
+ * @param {object} [options]
1161
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1162
+ * @returns {Stream}
1163
+ * An object stream which emits {@link protos.google.spanner.v1.CacheUpdate|CacheUpdate} on 'data' event.
1164
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
1165
+ * for more details and examples.
1166
+ */
1167
+ fetchCacheUpdate(request, options) {
1168
+ request = request || {};
1169
+ options = options || {};
1170
+ options.otherArgs = options.otherArgs || {};
1171
+ options.otherArgs.headers = options.otherArgs.headers || {};
1172
+ options.otherArgs.headers['x-goog-request-params'] =
1173
+ this._gaxModule.routingHeader.fromParams({
1174
+ database: request.database ?? '',
1175
+ });
1176
+ this.initialize().catch(err => {
1177
+ throw err;
1178
+ });
1179
+ this._log.info('fetchCacheUpdate stream %j', options);
1180
+ return this.innerApiCalls.fetchCacheUpdate(request, options);
1181
+ }
1137
1182
  listSessions(request, optionsOrCallback, callback) {
1138
1183
  request = request || {};
1139
1184
  let options;
@@ -112,6 +112,10 @@
112
112
  "timeout_millis": 3600000,
113
113
  "retry_codes_name": "non_idempotent",
114
114
  "retry_params_name": "default"
115
+ },
116
+ "FetchCacheUpdate": {
117
+ "retry_codes_name": "non_idempotent",
118
+ "retry_params_name": "default"
115
119
  }
116
120
  }
117
121
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "8.7.0",
4
+ "version": "8.8.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
@@ -34,8 +34,6 @@
34
34
  "docs": "jsdoc -c .jsdoc.js",
35
35
  "predocs": "npm run compile",
36
36
  "lint": "gts check",
37
- "samples-test-with-archived": "cd samples/ && npm link ../ && npm test-with-archived && cd ../",
38
- "samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
39
37
  "system-test": "mocha build/system-test --timeout 1600000",
40
38
  "observability-test": "mocha build/observability-test --timeout 1600000",
41
39
  "cleanup": "mocha scripts/cleanup.js --timeout 30000",
@@ -49,10 +47,7 @@
49
47
  "presystem-test": "npm run compile",
50
48
  "preobservability-test": "npm run compile",
51
49
  "proto": "compileProtos src",
52
- "docs-test": "linkinator docs",
53
- "predocs-test": "npm run docs",
54
50
  "benchwrapper": "node bin/benchwrapper.js",
55
- "prelint": "cd samples; npm link ../; npm install",
56
51
  "precompile": "gts clean",
57
52
  "compile-protos": "compileProtos src",
58
53
  "coverage": "c8 mocha build/test build/test/common && c8 report --check-coverage"
@@ -65,7 +60,6 @@
65
60
  "@google-cloud/monitoring": "^5.0.0",
66
61
  "@google-cloud/opentelemetry-resource-util": "^2.4.0",
67
62
  "@google-cloud/precise-date": "^5.0.0",
68
- "@google-cloud/projectify": "^5.0.0",
69
63
  "@google-cloud/promisify": "^5.0.0",
70
64
  "@grpc/grpc-js": "^1.13.2",
71
65
  "@grpc/proto-loader": "^0.8.0",
@@ -94,8 +88,7 @@
94
88
  "stack-trace": "0.0.10",
95
89
  "stream-events": "^1.0.5",
96
90
  "teeny-request": "^10.0.0",
97
- "through2": "^4.0.2",
98
- "uuid": "^11.1.0"
91
+ "through2": "^4.0.2"
99
92
  },
100
93
  "devDependencies": {
101
94
  "@grpc/reflection": "^1.0.4",
@@ -128,7 +121,6 @@
128
121
  "jsdoc": "^4.0.4",
129
122
  "jsdoc-fresh": "^5.0.0",
130
123
  "jsdoc-region-tag": "^4.0.0",
131
- "linkinator": "^6.1.2",
132
124
  "lodash.random": "^3.2.0",
133
125
  "long": "^5.3.2",
134
126
  "mocha": "^11.1.0",
@@ -156,4 +148,4 @@
156
148
  }
157
149
  },
158
150
  "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/handwritten/spanner"
159
- }
151
+ }