@google-cloud/spanner 8.13.0 → 9.1.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 +1 -16
- package/build/src/batch-transaction.js +15 -12
- package/build/src/codec.d.ts +18 -30
- package/build/src/codec.js +197 -79
- package/build/src/common.d.ts +14 -0
- package/build/src/common.js +28 -3
- package/build/src/database.d.ts +31 -41
- package/build/src/database.js +147 -315
- package/build/src/helper.d.ts +12 -0
- package/build/src/helper.js +44 -0
- package/build/src/index.d.ts +24 -8
- package/build/src/index.js +303 -147
- package/build/src/instance.d.ts +15 -2
- package/build/src/instance.js +11 -2
- package/build/src/instrument.d.ts +12 -1
- package/build/src/instrument.js +13 -0
- package/build/src/metrics/constants.d.ts +13 -6
- package/build/src/metrics/constants.js +24 -14
- package/build/src/metrics/external-types.d.ts +14 -0
- package/build/src/metrics/interceptor.js +39 -44
- package/build/src/metrics/metrics-tracer-factory.d.ts +25 -14
- package/build/src/metrics/metrics-tracer-factory.js +119 -78
- package/build/src/metrics/metrics-tracer.d.ts +19 -6
- package/build/src/metrics/metrics-tracer.js +147 -55
- package/build/src/metrics/spanner-metrics-exporter.js +4 -0
- package/build/src/metrics/transform.d.ts +3 -4
- package/build/src/metrics/transform.js +16 -10
- package/build/src/multiplexed-session.d.ts +26 -2
- package/build/src/multiplexed-session.js +39 -11
- package/build/src/partial-result-stream.d.ts +26 -33
- package/build/src/partial-result-stream.js +263 -283
- package/build/src/request-stream-coordinator.d.ts +88 -0
- package/build/src/request-stream-coordinator.js +229 -0
- package/build/src/request_id_header.d.ts +6 -4
- package/build/src/request_id_header.js +24 -24
- package/build/src/session-factory.d.ts +62 -60
- package/build/src/session-factory.js +46 -86
- package/build/src/session-pool.d.ts +97 -227
- package/build/src/session-pool.js +74 -547
- package/build/src/session.js +1 -1
- package/build/src/transaction-runner.js +1 -12
- package/build/src/transaction.d.ts +21 -5
- package/build/src/transaction.js +107 -136
- package/package.json +28 -37
package/build/src/helper.d.ts
CHANGED
|
@@ -15,30 +15,35 @@
|
|
|
15
15
|
import { grpc } from 'google-gax';
|
|
16
16
|
/**
|
|
17
17
|
* Checks whether the given error is a 'Database not found' error.
|
|
18
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
18
19
|
* @param {Error} error The error to check.
|
|
19
20
|
* @return {boolean} True if the error is a 'Database not found' error, and otherwise false.
|
|
20
21
|
*/
|
|
21
22
|
export declare function isDatabaseNotFoundError(error: grpc.ServiceError | undefined): boolean;
|
|
22
23
|
/**
|
|
23
24
|
* Checks whether the given error is an 'Instance not found' error.
|
|
25
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
24
26
|
* @param {Error} error The error to check.
|
|
25
27
|
* @return {boolean} True if the error is an 'Instance not found' error, and otherwise false.
|
|
26
28
|
*/
|
|
27
29
|
export declare function isInstanceNotFoundError(error: grpc.ServiceError | undefined): boolean;
|
|
28
30
|
/**
|
|
29
31
|
* Checks whether the given error is a 'Could not load the default credentials' error.
|
|
32
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
30
33
|
* @param {Error} error The error to check.
|
|
31
34
|
* @return {boolean} True if the error is a 'Could not load the default credentials' error, and otherwise false.
|
|
32
35
|
*/
|
|
33
36
|
export declare function isDefaultCredentialsNotSetError(error: grpc.ServiceError | undefined): boolean;
|
|
34
37
|
/**
|
|
35
38
|
* Checks whether the given error is an 'Unable to detect a Project Id in the current environment' error.
|
|
39
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
36
40
|
* @param {Error} error The error to check.
|
|
37
41
|
* @return {boolean} True if the error is an 'Unable to detect a Project Id in the current environment' error, and otherwise false.
|
|
38
42
|
*/
|
|
39
43
|
export declare function isProjectIdNotSetInEnvironmentError(error: grpc.ServiceError | undefined): boolean;
|
|
40
44
|
/**
|
|
41
45
|
* Checks whether the given error is a 'Create session permission' error.
|
|
46
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
42
47
|
* @param {Error} error The error to check.
|
|
43
48
|
* @return {boolean} True if the error is a 'Create session permission' error, and otherwise false.
|
|
44
49
|
*/
|
|
@@ -158,3 +163,10 @@ export declare function isUuid(value: any): boolean;
|
|
|
158
163
|
* @return {*} - The original argument with all placeholders populated.
|
|
159
164
|
*/
|
|
160
165
|
export declare function replaceProjectIdToken(value: any, projectId: string): any;
|
|
166
|
+
/**
|
|
167
|
+
* Checks whether an input value contains the `{{projectId}}` placeholder.
|
|
168
|
+
*
|
|
169
|
+
* @param {*} value - The value to inspect.
|
|
170
|
+
* @return {boolean} - `true` if any placeholder is found, otherwise `false`.
|
|
171
|
+
*/
|
|
172
|
+
export declare function hasProjectIdToken(value: any): boolean;
|
package/build/src/helper.js
CHANGED
|
@@ -37,10 +37,12 @@ exports.isInfinite = isInfinite;
|
|
|
37
37
|
exports.isError = isError;
|
|
38
38
|
exports.isUuid = isUuid;
|
|
39
39
|
exports.replaceProjectIdToken = replaceProjectIdToken;
|
|
40
|
+
exports.hasProjectIdToken = hasProjectIdToken;
|
|
40
41
|
const google_gax_1 = require("google-gax");
|
|
41
42
|
const stream_1 = require("stream");
|
|
42
43
|
/**
|
|
43
44
|
* Checks whether the given error is a 'Database not found' error.
|
|
45
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
44
46
|
* @param {Error} error The error to check.
|
|
45
47
|
* @return {boolean} True if the error is a 'Database not found' error, and otherwise false.
|
|
46
48
|
*/
|
|
@@ -51,6 +53,7 @@ function isDatabaseNotFoundError(error) {
|
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* Checks whether the given error is an 'Instance not found' error.
|
|
56
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
54
57
|
* @param {Error} error The error to check.
|
|
55
58
|
* @return {boolean} True if the error is an 'Instance not found' error, and otherwise false.
|
|
56
59
|
*/
|
|
@@ -61,6 +64,7 @@ function isInstanceNotFoundError(error) {
|
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Checks whether the given error is a 'Could not load the default credentials' error.
|
|
67
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
64
68
|
* @param {Error} error The error to check.
|
|
65
69
|
* @return {boolean} True if the error is a 'Could not load the default credentials' error, and otherwise false.
|
|
66
70
|
*/
|
|
@@ -70,6 +74,7 @@ function isDefaultCredentialsNotSetError(error) {
|
|
|
70
74
|
}
|
|
71
75
|
/**
|
|
72
76
|
* Checks whether the given error is an 'Unable to detect a Project Id in the current environment' error.
|
|
77
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
73
78
|
* @param {Error} error The error to check.
|
|
74
79
|
* @return {boolean} True if the error is an 'Unable to detect a Project Id in the current environment' error, and otherwise false.
|
|
75
80
|
*/
|
|
@@ -79,6 +84,7 @@ function isProjectIdNotSetInEnvironmentError(error) {
|
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
86
|
* Checks whether the given error is a 'Create session permission' error.
|
|
87
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
82
88
|
* @param {Error} error The error to check.
|
|
83
89
|
* @return {boolean} True if the error is a 'Create session permission' error, and otherwise false.
|
|
84
90
|
*/
|
|
@@ -325,6 +331,44 @@ function replaceProjectIdToken(value, projectId) {
|
|
|
325
331
|
}
|
|
326
332
|
return value;
|
|
327
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Checks whether an input value contains the `{{projectId}}` placeholder.
|
|
336
|
+
*
|
|
337
|
+
* @param {*} value - The value to inspect.
|
|
338
|
+
* @return {boolean} - `true` if any placeholder is found, otherwise `false`.
|
|
339
|
+
*/
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
|
+
function hasProjectIdToken(value) {
|
|
342
|
+
if (typeof value === 'string') {
|
|
343
|
+
return value.includes(PROJECT_ID_TOKEN);
|
|
344
|
+
}
|
|
345
|
+
if (value === null ||
|
|
346
|
+
typeof value !== 'object' ||
|
|
347
|
+
value instanceof Buffer ||
|
|
348
|
+
value instanceof stream_1.Stream ||
|
|
349
|
+
isDate(value)) {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
if (Array.isArray(value)) {
|
|
353
|
+
for (let i = 0; i < value.length; i++) {
|
|
354
|
+
if (hasProjectIdToken(value[i])) {
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
for (const key in value) {
|
|
361
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
362
|
+
if (!KEYS_TO_SCAN.has(key)) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (hasProjectIdToken(value[key])) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
328
372
|
/**
|
|
329
373
|
* Custom error type for missing project ID errors.
|
|
330
374
|
*/
|
package/build/src/index.d.ts
CHANGED
|
@@ -26,13 +26,14 @@ import { grpc, GrpcClientOptions, CallOptions } from 'google-gax';
|
|
|
26
26
|
import { protos } from '@google-cloud/spanner-api';
|
|
27
27
|
import google = protos.google;
|
|
28
28
|
import instanceAdmin = protos.google;
|
|
29
|
-
import { PagedOptions, PagedResponse, PagedCallback, PagedOptionsWithFilter, NormalCallback } from './common';
|
|
29
|
+
import { PagedOptions, PagedResponse, PagedCallback, PagedOptionsWithFilter, NormalCallback, isAFEServerTimingEnabled } from './common';
|
|
30
30
|
import { Session } from './session';
|
|
31
31
|
import { SessionPool } from './session-pool';
|
|
32
32
|
import { Table } from './table';
|
|
33
33
|
import { MutationGroup, MutationSet, PartitionedDml, Snapshot, Transaction } from './transaction';
|
|
34
34
|
import * as v1 from './v1';
|
|
35
35
|
import { ObservabilityOptions } from './instrument';
|
|
36
|
+
import { MetricsTracer } from './metrics/metrics-tracer';
|
|
36
37
|
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
37
38
|
export type GetInstancesOptions = PagedOptionsWithFilter;
|
|
38
39
|
export type GetInstancesResponse = PagedResponse<Instance, instanceAdmin.spanner.admin.instance.v1.IListInstancesResponse>;
|
|
@@ -57,6 +58,8 @@ export type GetInstanceConfigOperationsCallback = PagedCallback<IOperation, inst
|
|
|
57
58
|
* DirectedReadOptions won't be set for readWrite transactions"
|
|
58
59
|
* @property {ObservabilityOptions} [observabilityOptions] Sets the observability options to be used for OpenTelemetry tracing
|
|
59
60
|
* @property {boolean} [disableBuiltInMetrics=True] If set to true, built-in metrics will be disabled.
|
|
61
|
+
* @property {number} ['grpc.enable_channelz'=0] Whether to enable gRPC Channelz service tracking.
|
|
62
|
+
* Defaults to 0 (disabled) to eliminate per-RPC tracking and allocation overhead. Set to 1 to enable.
|
|
60
63
|
*/
|
|
61
64
|
export interface SpannerOptions extends GrpcClientOptions {
|
|
62
65
|
apiEndpoint?: string;
|
|
@@ -83,6 +86,12 @@ export interface SpannerOptions extends GrpcClientOptions {
|
|
|
83
86
|
*/
|
|
84
87
|
universe_domain?: string;
|
|
85
88
|
universeDomain?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Whether to enable gRPC Channelz service tracking.
|
|
91
|
+
* Defaults to `0` (disabled) to eliminate per-RPC allocation and tracking overhead.
|
|
92
|
+
* Set to `1` if live connection introspection via gRPC Channelz (e.g. grpcdebug) is required.
|
|
93
|
+
*/
|
|
94
|
+
'grpc.enable_channelz'?: number;
|
|
86
95
|
}
|
|
87
96
|
export interface RequestConfig {
|
|
88
97
|
client: string;
|
|
@@ -92,6 +101,7 @@ export interface RequestConfig {
|
|
|
92
101
|
headers: {
|
|
93
102
|
[k: string]: string;
|
|
94
103
|
};
|
|
104
|
+
metricsTracer?: MetricsTracer;
|
|
95
105
|
}
|
|
96
106
|
export interface CreateInstanceRequest {
|
|
97
107
|
config?: string;
|
|
@@ -197,8 +207,8 @@ declare class Spanner extends GrpcService {
|
|
|
197
207
|
private _universeDomain;
|
|
198
208
|
private _isInSecureCredentials;
|
|
199
209
|
private _metricsEnabled;
|
|
200
|
-
private static _isAFEServerTimingEnabled;
|
|
201
210
|
readonly _nthClientId: number;
|
|
211
|
+
private _pendingProjectIdCallbacks?;
|
|
202
212
|
/**
|
|
203
213
|
* Placeholder used to auto populate a column with the commit timestamp.
|
|
204
214
|
* This can only be used for timestamp columns that have set the option
|
|
@@ -213,14 +223,14 @@ declare class Spanner extends GrpcService {
|
|
|
213
223
|
* Returns whether AFE (Application Frontend Extension) server timing is enabled.
|
|
214
224
|
*
|
|
215
225
|
* This method checks the value of the environment variable
|
|
216
|
-
* `SPANNER_DISABLE_AFE_SERVER_TIMING`. If the variable is explicitly set to
|
|
217
|
-
* string `'true'
|
|
218
|
-
* returns `false`. For all other
|
|
219
|
-
* the method returns `true`.
|
|
226
|
+
* `SPANNER_DISABLE_AFE_SERVER_TIMING`. If the variable is explicitly set to
|
|
227
|
+
* the string `'true'` (case-insensitive), then AFE server timing is
|
|
228
|
+
* considered disabled, and this method returns `false`. For all other
|
|
229
|
+
* values (including if the variable is unset), the method returns `true`.
|
|
220
230
|
*
|
|
221
231
|
* @returns {boolean} `true` if AFE server timing is enabled; otherwise, `false`.
|
|
222
232
|
*/
|
|
223
|
-
static isAFEServerTimingEnabled:
|
|
233
|
+
static isAFEServerTimingEnabled: typeof isAFEServerTimingEnabled;
|
|
224
234
|
/** Resets the cached value (use in tests if env changes). */
|
|
225
235
|
static _resetAFEServerTimingForTest(): void;
|
|
226
236
|
/**
|
|
@@ -871,7 +881,10 @@ declare class Spanner extends GrpcService {
|
|
|
871
881
|
* @param {object} config Request config
|
|
872
882
|
* @param {function} callback Callback function
|
|
873
883
|
*/
|
|
874
|
-
prepareGapicRequest_(config:
|
|
884
|
+
prepareGapicRequest_(config: RequestConfig, callback: (err: Error | null, requestFn?: any) => void): void;
|
|
885
|
+
private _prepareGapicRequestWithProjectId;
|
|
886
|
+
private _getResourceName;
|
|
887
|
+
private _initMetricsTracer;
|
|
875
888
|
/**
|
|
876
889
|
* Funnel all API requests through this method to be sure we have a project
|
|
877
890
|
* ID.
|
|
@@ -1187,6 +1200,9 @@ export { Session };
|
|
|
1187
1200
|
/**
|
|
1188
1201
|
* {@link SessionPool} class.
|
|
1189
1202
|
*
|
|
1203
|
+
* @deprecated Session pool is deprecated and will be removed in a future release.
|
|
1204
|
+
* Multiplexed sessions are now used for all operations by default, eliminating
|
|
1205
|
+
* the need for session pooling.
|
|
1190
1206
|
* @name Spanner.SessionPool
|
|
1191
1207
|
* @see SessionPool
|
|
1192
1208
|
* @type {Constructor}
|