@google-cloud/spanner 8.3.1 → 8.5.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/google/spanner/admin/instance/v1/spanner_instance_admin.proto +70 -3
- package/build/protos/google/spanner/v1/location.proto +388 -0
- package/build/protos/google/spanner/v1/mutation.proto +41 -0
- package/build/protos/google/spanner/v1/query_plan.proto +25 -0
- package/build/protos/google/spanner/v1/result_set.proto +9 -0
- package/build/protos/google/spanner/v1/spanner.proto +35 -6
- package/build/protos/google/spanner/v1/transaction.proto +4 -2
- package/build/protos/protos.d.ts +2344 -619
- package/build/protos/protos.js +7358 -2472
- package/build/protos/protos.json +513 -72
- package/build/src/codec.d.ts +1 -0
- package/build/src/codec.js +13 -0
- package/build/src/instrument.js +1 -0
- package/build/src/multiplexed-session.d.ts +15 -24
- package/build/src/multiplexed-session.js +71 -78
- package/build/src/session-factory.js +7 -12
- package/build/src/table.d.ts +3 -1
- package/build/src/transaction.js +20 -2
- package/build/src/v1/database_admin_client.js +1 -1
- package/build/src/v1/instance_admin_client.js +1 -1
- package/build/src/v1/spanner_client.d.ts +32 -4
- package/build/src/v1/spanner_client.js +15 -1
- package/build/src/v1/spanner_executor_proxy_client.js +1 -1
- package/build/src/v1/spanner_executor_proxy_proto_list.json +1 -0
- package/build/src/v1/spanner_proto_list.json +1 -0
- package/package.json +3 -3
package/build/src/codec.js
CHANGED
|
@@ -22,6 +22,8 @@ const helper_1 = require("./helper");
|
|
|
22
22
|
const big_js_1 = require("big.js");
|
|
23
23
|
const protos_1 = require("../protos/protos");
|
|
24
24
|
const google_gax_1 = require("google-gax");
|
|
25
|
+
const uuid = require("uuid");
|
|
26
|
+
let uuidUntypedFlagWarned = false;
|
|
25
27
|
/**
|
|
26
28
|
* Date-like object used to represent Cloud Spanner Dates. DATE types represent
|
|
27
29
|
* a logical calendar date, independent of time zone. DATE values do not
|
|
@@ -811,6 +813,7 @@ const TypeCode = {
|
|
|
811
813
|
bool: 'BOOL',
|
|
812
814
|
int64: 'INT64',
|
|
813
815
|
pgOid: 'INT64',
|
|
816
|
+
uuid: 'UUID',
|
|
814
817
|
float32: 'FLOAT32',
|
|
815
818
|
float64: 'FLOAT64',
|
|
816
819
|
numeric: 'NUMERIC',
|
|
@@ -834,6 +837,7 @@ const TypeCode = {
|
|
|
834
837
|
/**
|
|
835
838
|
* @typedef {object} ParamType
|
|
836
839
|
* @property {string} type The param type. Must be one of the following:
|
|
840
|
+
* - uuid
|
|
837
841
|
* - float32
|
|
838
842
|
* - float64
|
|
839
843
|
* - int64
|
|
@@ -903,6 +907,15 @@ function getType(value) {
|
|
|
903
907
|
if ((0, helper_1.isBoolean)(value)) {
|
|
904
908
|
return { type: 'bool' };
|
|
905
909
|
}
|
|
910
|
+
if (process.env['SPANNER_ENABLE_UUID_AS_UNTYPED'] === 'true') {
|
|
911
|
+
if (!uuidUntypedFlagWarned) {
|
|
912
|
+
process.emitWarning('SPANNER_ENABLE_UUID_AS_UNTYPED environment variable is deprecated and will be removed in a future release.', 'DeprecationWarning');
|
|
913
|
+
uuidUntypedFlagWarned = true;
|
|
914
|
+
}
|
|
915
|
+
if (uuid.validate(value)) {
|
|
916
|
+
return { type: 'unspecified' };
|
|
917
|
+
}
|
|
918
|
+
}
|
|
906
919
|
if ((0, helper_1.isString)(value)) {
|
|
907
920
|
return { type: 'string' };
|
|
908
921
|
}
|
package/build/src/instrument.js
CHANGED
|
@@ -87,6 +87,7 @@ function startTrace(spanNameSuffix, config, cb) {
|
|
|
87
87
|
span.setAttribute('db.sql.table', config.tableName);
|
|
88
88
|
}
|
|
89
89
|
if (config.dbName) {
|
|
90
|
+
span.setAttribute('gcp.resource.name', `//spanner.googleapis.com/${config.dbName}`);
|
|
90
91
|
span.setAttribute('db.name', config.dbName);
|
|
91
92
|
}
|
|
92
93
|
if (config.requestTag) {
|
|
@@ -18,8 +18,6 @@ import { Database } from './database';
|
|
|
18
18
|
import { Session } from './session';
|
|
19
19
|
import { GetSessionCallback } from './session-factory';
|
|
20
20
|
import { ObservabilityOptions } from './instrument';
|
|
21
|
-
export declare const MUX_SESSION_AVAILABLE = "mux-session-available";
|
|
22
|
-
export declare const MUX_SESSION_CREATE_ERROR = "mux-session-create-error";
|
|
23
21
|
/**
|
|
24
22
|
* Interface for implementing multiplexed session logic, it should extend the
|
|
25
23
|
* {@link https://nodejs.org/api/events.html|EventEmitter} class
|
|
@@ -58,13 +56,16 @@ export declare class MultiplexedSession extends EventEmitter implements Multiple
|
|
|
58
56
|
database: Database;
|
|
59
57
|
refreshRate: number;
|
|
60
58
|
_multiplexedSession: Session | null;
|
|
61
|
-
_refreshHandle: NodeJS.
|
|
59
|
+
_refreshHandle: NodeJS.Timeout;
|
|
62
60
|
_observabilityOptions?: ObservabilityOptions;
|
|
61
|
+
_sharedMuxSessionWaitPromise: Promise<void> | null;
|
|
63
62
|
constructor(database: Database);
|
|
64
63
|
/**
|
|
65
64
|
* Creates a new multiplexed session and manages its maintenance.
|
|
66
65
|
*
|
|
67
66
|
* This method initiates the session creation process by calling the `_createSession` method, which returns a Promise.
|
|
67
|
+
*
|
|
68
|
+
* Errors are silently swallowed here to prevent unhandled promise rejections or application crashes during background operations.
|
|
68
69
|
*/
|
|
69
70
|
createSession(): void;
|
|
70
71
|
/**
|
|
@@ -73,10 +74,8 @@ export declare class MultiplexedSession extends EventEmitter implements Multiple
|
|
|
73
74
|
* This method sends a request to the database to create a new session with multiplexing enabled.
|
|
74
75
|
* The response from the database would be an array, the first value of the array will be containing the multiplexed session.
|
|
75
76
|
*
|
|
76
|
-
* @returns {Promise<void>}
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* In case of error, an error will get emitted along with the error event.
|
|
77
|
+
* @returns {Promise<void>} Resolves when the session is successfully created.
|
|
78
|
+
* @throws {Error} If the request fails, the error is thrown to the caller.
|
|
80
79
|
*
|
|
81
80
|
* @private
|
|
82
81
|
*/
|
|
@@ -92,6 +91,9 @@ export declare class MultiplexedSession extends EventEmitter implements Multiple
|
|
|
92
91
|
* and ignored. This is because the currently active multiplexed session has a 30-day expiry, providing
|
|
93
92
|
* the maintainer with four opportunities (one every 7 days) to refresh the active session.
|
|
94
93
|
*
|
|
94
|
+
* Hence, if the `_createSession` fails here, the system will either simply retry at the next interval or
|
|
95
|
+
* upon the next user request if the session expires.
|
|
96
|
+
*
|
|
95
97
|
* @returns {void} This method does not return any value.
|
|
96
98
|
*
|
|
97
99
|
*/
|
|
@@ -105,28 +107,17 @@ export declare class MultiplexedSession extends EventEmitter implements Multiple
|
|
|
105
107
|
*
|
|
106
108
|
*/
|
|
107
109
|
getSession(callback: GetSessionCallback): void;
|
|
108
|
-
/**
|
|
109
|
-
* Acquires a session asynchronously.
|
|
110
|
-
*
|
|
111
|
-
* Once a session is successfully acquired, it returns the session object (which may be `null` if unsuccessful).
|
|
112
|
-
*
|
|
113
|
-
* @returns {Promise<Session | null>}
|
|
114
|
-
* A Promise that resolves with the acquired session (or `null` if no session is available after retries).
|
|
115
|
-
*
|
|
116
|
-
*/
|
|
117
|
-
_acquire(): Promise<Session | null>;
|
|
118
110
|
/**
|
|
119
111
|
* Attempts to get a session, waiting for it to become available if necessary.
|
|
120
112
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
113
|
+
* Logic Flow:
|
|
114
|
+
* 1. Cache Hit: If a session exists, return it immediately.
|
|
115
|
+
* 2. Join Wait: If another request is currently creating the session (`_sharedMuxSessionWaitPromise` exists), await it.
|
|
116
|
+
* 3. Create: If neither, initiate a new creation request (`_createSession`).
|
|
125
117
|
*
|
|
126
|
-
* In case of an error, the promise will get rejected and the error will get bubble up to the parent method.
|
|
118
|
+
* @throws {Error} In case of an error, the promise will get rejected and the error will get bubble up to the parent method.
|
|
127
119
|
*
|
|
128
|
-
* @returns {Promise<Session | null>} A promise that resolves with the
|
|
129
|
-
* or `null` if the session is not available.
|
|
120
|
+
* @returns {Promise<Session | null>} A promise that resolves with the active multiplexed session.
|
|
130
121
|
*
|
|
131
122
|
* @private
|
|
132
123
|
*
|
|
@@ -15,11 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.MultiplexedSession =
|
|
18
|
+
exports.MultiplexedSession = void 0;
|
|
19
19
|
const events_1 = require("events");
|
|
20
20
|
const instrument_1 = require("./instrument");
|
|
21
|
-
exports.MUX_SESSION_AVAILABLE = 'mux-session-available';
|
|
22
|
-
exports.MUX_SESSION_CREATE_ERROR = 'mux-session-create-error';
|
|
23
21
|
/**
|
|
24
22
|
* Class used to manage connections to Spanner using multiplexed session.
|
|
25
23
|
*
|
|
@@ -36,6 +34,8 @@ class MultiplexedSession extends events_1.EventEmitter {
|
|
|
36
34
|
_multiplexedSession;
|
|
37
35
|
_refreshHandle;
|
|
38
36
|
_observabilityOptions;
|
|
37
|
+
// shared promise lock to handle concurrent session creation requests
|
|
38
|
+
_sharedMuxSessionWaitPromise;
|
|
39
39
|
constructor(database) {
|
|
40
40
|
super();
|
|
41
41
|
this.database = database;
|
|
@@ -43,20 +43,23 @@ class MultiplexedSession extends events_1.EventEmitter {
|
|
|
43
43
|
this.refreshRate = 7;
|
|
44
44
|
this._multiplexedSession = null;
|
|
45
45
|
this._observabilityOptions = database._observabilityOptions;
|
|
46
|
+
this._sharedMuxSessionWaitPromise = null;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* Creates a new multiplexed session and manages its maintenance.
|
|
49
50
|
*
|
|
50
51
|
* This method initiates the session creation process by calling the `_createSession` method, which returns a Promise.
|
|
52
|
+
*
|
|
53
|
+
* Errors are silently swallowed here to prevent unhandled promise rejections or application crashes during background operations.
|
|
51
54
|
*/
|
|
52
55
|
createSession() {
|
|
53
56
|
this._createSession()
|
|
54
57
|
.then(() => {
|
|
55
58
|
this._maintain();
|
|
56
59
|
})
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
// Ignore errors here. If this fails, the next user request will
|
|
61
|
+
// automatically trigger a retry via `_getSession`.
|
|
62
|
+
.catch(err => { });
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* Creates a new multiplexed session.
|
|
@@ -64,37 +67,46 @@ class MultiplexedSession extends events_1.EventEmitter {
|
|
|
64
67
|
* This method sends a request to the database to create a new session with multiplexing enabled.
|
|
65
68
|
* The response from the database would be an array, the first value of the array will be containing the multiplexed session.
|
|
66
69
|
*
|
|
67
|
-
* @returns {Promise<void>}
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* In case of error, an error will get emitted along with the error event.
|
|
70
|
+
* @returns {Promise<void>} Resolves when the session is successfully created.
|
|
71
|
+
* @throws {Error} If the request fails, the error is thrown to the caller.
|
|
71
72
|
*
|
|
72
73
|
* @private
|
|
73
74
|
*/
|
|
74
75
|
async _createSession() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// If a session is already being created, just wait for it to complete.
|
|
77
|
+
if (this._sharedMuxSessionWaitPromise) {
|
|
78
|
+
return this._sharedMuxSessionWaitPromise;
|
|
79
|
+
}
|
|
80
|
+
// Define the async task that performs the actual session creation and tracing.
|
|
81
|
+
const task = async () => {
|
|
82
|
+
const traceConfig = {
|
|
83
|
+
opts: this._observabilityOptions,
|
|
84
|
+
dbName: this.database.formattedName_,
|
|
85
|
+
};
|
|
86
|
+
return (0, instrument_1.startTrace)('MultiplexedSession.createSession', traceConfig, async (span) => {
|
|
87
|
+
span.addEvent('Requesting a multiplexed session');
|
|
88
|
+
try {
|
|
89
|
+
const [createSessionResponse] = await this.database.createSession({
|
|
90
|
+
multiplexed: true,
|
|
91
|
+
});
|
|
92
|
+
this._multiplexedSession = createSessionResponse;
|
|
93
|
+
span.addEvent('Created a multiplexed session');
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
(0, instrument_1.setSpanError)(span, e);
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
span.end();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
78
103
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
multiplexed: true,
|
|
84
|
-
});
|
|
85
|
-
this._multiplexedSession = createSessionResponse;
|
|
86
|
-
span.addEvent('Created a multiplexed session');
|
|
87
|
-
this.emit(exports.MUX_SESSION_AVAILABLE);
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
(0, instrument_1.setSpanError)(span, e);
|
|
91
|
-
this.emit(exports.MUX_SESSION_CREATE_ERROR, e);
|
|
92
|
-
throw e;
|
|
93
|
-
}
|
|
94
|
-
finally {
|
|
95
|
-
span.end();
|
|
96
|
-
}
|
|
104
|
+
// Assign the running task to the shared promise variable, and ensure
|
|
105
|
+
// the lock is released when it completes.
|
|
106
|
+
this._sharedMuxSessionWaitPromise = task().finally(() => {
|
|
107
|
+
this._sharedMuxSessionWaitPromise = null;
|
|
97
108
|
});
|
|
109
|
+
return this._sharedMuxSessionWaitPromise;
|
|
98
110
|
}
|
|
99
111
|
/**
|
|
100
112
|
* Maintains the multiplexed session by periodically refreshing it.
|
|
@@ -107,19 +119,25 @@ class MultiplexedSession extends events_1.EventEmitter {
|
|
|
107
119
|
* and ignored. This is because the currently active multiplexed session has a 30-day expiry, providing
|
|
108
120
|
* the maintainer with four opportunities (one every 7 days) to refresh the active session.
|
|
109
121
|
*
|
|
122
|
+
* Hence, if the `_createSession` fails here, the system will either simply retry at the next interval or
|
|
123
|
+
* upon the next user request if the session expires.
|
|
124
|
+
*
|
|
110
125
|
* @returns {void} This method does not return any value.
|
|
111
126
|
*
|
|
112
127
|
*/
|
|
113
128
|
_maintain() {
|
|
129
|
+
// If a maintenance loop is already running, stop it first.
|
|
130
|
+
// This prevents creating duplicate intervals if _maintain is called multiple times.
|
|
131
|
+
if (this._refreshHandle) {
|
|
132
|
+
clearInterval(this._refreshHandle);
|
|
133
|
+
}
|
|
114
134
|
const refreshRate = this.refreshRate * 24 * 60 * 60000;
|
|
115
135
|
this._refreshHandle = setInterval(async () => {
|
|
116
|
-
|
|
117
|
-
await this._createSession();
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
136
|
+
await this._createSession().catch(() => { });
|
|
122
137
|
}, refreshRate);
|
|
138
|
+
// Unreference the timer so it does not prevent the Node.js process from exiting.
|
|
139
|
+
// If the application has finished all other work, this background timer shouldn't
|
|
140
|
+
// force the process to stay open.
|
|
123
141
|
this._refreshHandle.unref();
|
|
124
142
|
}
|
|
125
143
|
/**
|
|
@@ -131,35 +149,19 @@ class MultiplexedSession extends events_1.EventEmitter {
|
|
|
131
149
|
*
|
|
132
150
|
*/
|
|
133
151
|
getSession(callback) {
|
|
134
|
-
this.
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Acquires a session asynchronously.
|
|
138
|
-
*
|
|
139
|
-
* Once a session is successfully acquired, it returns the session object (which may be `null` if unsuccessful).
|
|
140
|
-
*
|
|
141
|
-
* @returns {Promise<Session | null>}
|
|
142
|
-
* A Promise that resolves with the acquired session (or `null` if no session is available after retries).
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
async _acquire() {
|
|
146
|
-
const span = (0, instrument_1.getActiveOrNoopSpan)();
|
|
147
|
-
const session = await this._getSession();
|
|
148
|
-
span.addEvent('Acquired multiplexed session');
|
|
149
|
-
return session;
|
|
152
|
+
this._getSession().then(session => callback(null, session, session.transaction(session.parent.queryOptions_)), callback);
|
|
150
153
|
}
|
|
151
154
|
/**
|
|
152
155
|
* Attempts to get a session, waiting for it to become available if necessary.
|
|
153
156
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
157
|
+
* Logic Flow:
|
|
158
|
+
* 1. Cache Hit: If a session exists, return it immediately.
|
|
159
|
+
* 2. Join Wait: If another request is currently creating the session (`_sharedMuxSessionWaitPromise` exists), await it.
|
|
160
|
+
* 3. Create: If neither, initiate a new creation request (`_createSession`).
|
|
158
161
|
*
|
|
159
|
-
* In case of an error, the promise will get rejected and the error will get bubble up to the parent method.
|
|
162
|
+
* @throws {Error} In case of an error, the promise will get rejected and the error will get bubble up to the parent method.
|
|
160
163
|
*
|
|
161
|
-
* @returns {Promise<Session | null>} A promise that resolves with the
|
|
162
|
-
* or `null` if the session is not available.
|
|
164
|
+
* @returns {Promise<Session | null>} A promise that resolves with the active multiplexed session.
|
|
163
165
|
*
|
|
164
166
|
* @private
|
|
165
167
|
*
|
|
@@ -171,27 +173,18 @@ class MultiplexedSession extends events_1.EventEmitter {
|
|
|
171
173
|
span.addEvent('Cache hit: has usable multiplexed session');
|
|
172
174
|
return this._multiplexedSession;
|
|
173
175
|
}
|
|
174
|
-
// Define event and promises to wait for the session to become available or for the error
|
|
175
176
|
span.addEvent('Waiting for a multiplexed session to become available');
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
new Promise((_, reject) => {
|
|
180
|
-
this.once(exports.MUX_SESSION_CREATE_ERROR, reject);
|
|
181
|
-
removeErrorListener = this.removeListener.bind(this, exports.MUX_SESSION_CREATE_ERROR, reject);
|
|
182
|
-
}),
|
|
183
|
-
new Promise(resolve => {
|
|
184
|
-
this.once(exports.MUX_SESSION_AVAILABLE, resolve);
|
|
185
|
-
removeAvailableListener = this.removeListener.bind(this, exports.MUX_SESSION_AVAILABLE, resolve);
|
|
186
|
-
}),
|
|
187
|
-
];
|
|
188
|
-
try {
|
|
189
|
-
await Promise.race(promises);
|
|
177
|
+
// If initialization is ALREADY in progress, join the existing line!
|
|
178
|
+
if (this._sharedMuxSessionWaitPromise) {
|
|
179
|
+
await this._sharedMuxSessionWaitPromise;
|
|
190
180
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
else {
|
|
182
|
+
// If the session is null, and nobody is currently initializing it
|
|
183
|
+
// It means a previous attempt failed and we are in a "Dead" state
|
|
184
|
+
// We must kickstart the process again
|
|
185
|
+
await this._createSession();
|
|
194
186
|
}
|
|
187
|
+
span.addEvent('Acquired multiplexed session');
|
|
195
188
|
// Return the multiplexed session after it becomes available
|
|
196
189
|
return this._multiplexedSession;
|
|
197
190
|
}
|
|
@@ -41,28 +41,23 @@ class SessionFactory extends common.GrpcServiceObject {
|
|
|
41
41
|
parent: database,
|
|
42
42
|
id: name,
|
|
43
43
|
});
|
|
44
|
+
// initialize regular pool
|
|
44
45
|
this.pool_ =
|
|
45
46
|
typeof poolOptions === 'function'
|
|
46
47
|
? new poolOptions(database, null)
|
|
47
48
|
: new session_pool_1.SessionPool(database, poolOptions);
|
|
49
|
+
// initialize multiplexed session
|
|
48
50
|
this.multiplexedSession_ = new multiplexed_session_1.MultiplexedSession(database);
|
|
49
|
-
this.multiplexedSession_.on('error', this.emit.bind(database, 'error'));
|
|
50
51
|
this.multiplexedSession_.createSession();
|
|
51
52
|
// set the isMultiplexed property to false if multiplexed session is disabled, otherwise set the property to true
|
|
52
|
-
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'false'
|
|
53
|
-
? (this.isMultiplexed = false)
|
|
54
|
-
: (this.isMultiplexed = true);
|
|
53
|
+
this.isMultiplexed = !(process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'false');
|
|
55
54
|
// set the isMultiplexedPartitionedOps property to false if multiplexed session is disabled for paritioned ops, otherwise set the property to true
|
|
56
|
-
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'false' &&
|
|
55
|
+
this.isMultiplexedPartitionOps = !(process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'false' &&
|
|
57
56
|
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS ===
|
|
58
|
-
'false'
|
|
59
|
-
? (this.isMultiplexedPartitionOps = false)
|
|
60
|
-
: (this.isMultiplexedPartitionOps = true);
|
|
57
|
+
'false');
|
|
61
58
|
// set the isMultiplexedRW property to false if multiplexed session is disabled for read/write, otherwise set the property to true
|
|
62
|
-
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'false' &&
|
|
63
|
-
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_FOR_RW === 'false'
|
|
64
|
-
? (this.isMultiplexedRW = false)
|
|
65
|
-
: (this.isMultiplexedRW = true);
|
|
59
|
+
this.isMultiplexedRW = !(process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS === 'false' &&
|
|
60
|
+
process.env.GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_FOR_RW === 'false');
|
|
66
61
|
// Regular sessions should only be created if mux is disabled.
|
|
67
62
|
if (!this.isMultiplexed) {
|
|
68
63
|
this.pool_.on('error', this.emit.bind(database, 'error'));
|
package/build/src/table.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ import { ObservabilityOptions } from './instrument';
|
|
|
24
24
|
import { google } from '../protos/protos';
|
|
25
25
|
import IsolationLevel = google.spanner.v1.TransactionOptions.IsolationLevel;
|
|
26
26
|
import ReadLockMode = google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode;
|
|
27
|
-
|
|
27
|
+
import { Int, SpannerDate, Numeric, Float32, Float } from './codec';
|
|
28
|
+
export type KeyScalar = string | number | boolean | SpannerDate | Buffer | Uint8Array | Int | Numeric | Float32 | Float;
|
|
29
|
+
export type Key = KeyScalar | KeyScalar[];
|
|
28
30
|
export type CreateTableResponse = [
|
|
29
31
|
Table,
|
|
30
32
|
GaxOperation,
|
package/build/src/transaction.js
CHANGED
|
@@ -720,9 +720,16 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
720
720
|
...this._traceConfig,
|
|
721
721
|
}, span => {
|
|
722
722
|
return this.runStream(query)
|
|
723
|
-
.on('error',
|
|
723
|
+
.on('error', err => {
|
|
724
724
|
(0, instrument_1.setSpanError)(span, err);
|
|
725
725
|
span.end();
|
|
726
|
+
if (!('code' in err)) {
|
|
727
|
+
Object.assign(err, {
|
|
728
|
+
code: google_gax_1.grpc.status.UNKNOWN,
|
|
729
|
+
details: err.message,
|
|
730
|
+
metadata: new google_gax_1.grpc.Metadata(),
|
|
731
|
+
});
|
|
732
|
+
}
|
|
726
733
|
callback(err, rows, stats, metadata);
|
|
727
734
|
})
|
|
728
735
|
.on('response', response => {
|
|
@@ -1081,7 +1088,18 @@ class Snapshot extends events_1.EventEmitter {
|
|
|
1081
1088
|
if (!(0, helper_1.isEmpty)(typeMap)) {
|
|
1082
1089
|
Object.keys(typeMap).forEach(param => {
|
|
1083
1090
|
const type = typeMap[param];
|
|
1084
|
-
|
|
1091
|
+
if (process.env['SPANNER_ENABLE_UUID_AS_UNTYPED'] === 'true') {
|
|
1092
|
+
const typeObject = codec_1.codec.createTypeObject(type);
|
|
1093
|
+
if ((type.child &&
|
|
1094
|
+
typeObject.code === 'ARRAY' &&
|
|
1095
|
+
typeObject.arrayElementType?.code !== 'TYPE_CODE_UNSPECIFIED') ||
|
|
1096
|
+
(!type.child && typeObject.code !== 'TYPE_CODE_UNSPECIFIED')) {
|
|
1097
|
+
paramTypes[param] = typeObject;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
paramTypes[param] = codec_1.codec.createTypeObject(type);
|
|
1102
|
+
}
|
|
1085
1103
|
});
|
|
1086
1104
|
}
|
|
1087
1105
|
return { params, paramTypes };
|
|
@@ -172,10 +172,10 @@ export declare class SpannerClient {
|
|
|
172
172
|
* @param {google.spanner.v1.Session} request.sessionTemplate
|
|
173
173
|
* Parameters to apply to each created session.
|
|
174
174
|
* @param {number} request.sessionCount
|
|
175
|
-
* Required. The number of sessions to be created in this batch call.
|
|
176
|
-
* The API can return fewer than the requested number
|
|
177
|
-
* specific number of sessions are desired, the client can
|
|
178
|
-
* calls to `BatchCreateSessions` (adjusting
|
|
175
|
+
* Required. The number of sessions to be created in this batch call. At least
|
|
176
|
+
* one session is created. The API can return fewer than the requested number
|
|
177
|
+
* of sessions. If a specific number of sessions are desired, the client can
|
|
178
|
+
* make additional calls to `BatchCreateSessions` (adjusting
|
|
179
179
|
* {@link protos.google.spanner.v1.BatchCreateSessionsRequest.session_count|session_count}
|
|
180
180
|
* as necessary).
|
|
181
181
|
* @param {object} [options]
|
|
@@ -349,6 +349,13 @@ export declare class SpannerClient {
|
|
|
349
349
|
* be deferred until commit time (for example, validation of unique
|
|
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
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
353
|
+
* Optional. If present, it makes the Spanner requests location-aware.
|
|
354
|
+
*
|
|
355
|
+
* It gives the server hints that can be used to route the request
|
|
356
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
357
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
358
|
+
* filled in with accurate values.
|
|
352
359
|
* @param {object} [options]
|
|
353
360
|
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
354
361
|
* @returns {Promise} - The promise which resolves to an array.
|
|
@@ -519,6 +526,13 @@ export declare class SpannerClient {
|
|
|
519
526
|
* @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint]
|
|
520
527
|
* Optional. Lock Hint for the request, it can only be used with read-write
|
|
521
528
|
* transactions.
|
|
529
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
530
|
+
* Optional. If present, it makes the Spanner requests location-aware.
|
|
531
|
+
*
|
|
532
|
+
* It gives the server hints that can be used to route the request
|
|
533
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
534
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
535
|
+
* filled in with accurate values.
|
|
522
536
|
* @param {object} [options]
|
|
523
537
|
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
524
538
|
* @returns {Promise} - The promise which resolves to an array.
|
|
@@ -908,6 +922,13 @@ export declare class SpannerClient {
|
|
|
908
922
|
* be deferred until commit time (for example, validation of unique
|
|
909
923
|
* constraints). Given this, successful execution of a DML statement shouldn't
|
|
910
924
|
* be assumed until a subsequent `Commit` call completes successfully.
|
|
925
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
926
|
+
* Optional. If present, it makes the Spanner requests location-aware.
|
|
927
|
+
*
|
|
928
|
+
* It gives the server hints that can be used to route the request
|
|
929
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
930
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
931
|
+
* filled in with accurate values.
|
|
911
932
|
* @param {object} [options]
|
|
912
933
|
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
913
934
|
* @returns {Stream}
|
|
@@ -997,6 +1018,13 @@ export declare class SpannerClient {
|
|
|
997
1018
|
* @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint]
|
|
998
1019
|
* Optional. Lock Hint for the request, it can only be used with read-write
|
|
999
1020
|
* transactions.
|
|
1021
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
1022
|
+
* Optional. If present, it makes the Spanner requests location-aware.
|
|
1023
|
+
*
|
|
1024
|
+
* It gives the server hints that can be used to route the request
|
|
1025
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
1026
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
1027
|
+
* filled in with accurate values.
|
|
1000
1028
|
* @param {object} [options]
|
|
1001
1029
|
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1002
1030
|
* @returns {Stream}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Google LLC
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -944,6 +944,13 @@ class SpannerClient {
|
|
|
944
944
|
* be deferred until commit time (for example, validation of unique
|
|
945
945
|
* constraints). Given this, successful execution of a DML statement shouldn't
|
|
946
946
|
* be assumed until a subsequent `Commit` call completes successfully.
|
|
947
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
948
|
+
* Optional. If present, it makes the Spanner requests location-aware.
|
|
949
|
+
*
|
|
950
|
+
* It gives the server hints that can be used to route the request
|
|
951
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
952
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
953
|
+
* filled in with accurate values.
|
|
947
954
|
* @param {object} [options]
|
|
948
955
|
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
949
956
|
* @returns {Stream}
|
|
@@ -1047,6 +1054,13 @@ class SpannerClient {
|
|
|
1047
1054
|
* @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint]
|
|
1048
1055
|
* Optional. Lock Hint for the request, it can only be used with read-write
|
|
1049
1056
|
* transactions.
|
|
1057
|
+
* @param {google.spanner.v1.RoutingHint} [request.routingHint]
|
|
1058
|
+
* Optional. If present, it makes the Spanner requests location-aware.
|
|
1059
|
+
*
|
|
1060
|
+
* It gives the server hints that can be used to route the request
|
|
1061
|
+
* to an appropriate server, potentially significantly decreasing latency and
|
|
1062
|
+
* improving throughput. To achieve improved performance, most fields must be
|
|
1063
|
+
* filled in with accurate values.
|
|
1050
1064
|
* @param {object} [options]
|
|
1051
1065
|
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
|
1052
1066
|
* @returns {Stream}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"../../protos/google/spanner/executor/v1/cloud_executor.proto",
|
|
7
7
|
"../../protos/google/spanner/v1/commit_response.proto",
|
|
8
8
|
"../../protos/google/spanner/v1/keys.proto",
|
|
9
|
+
"../../protos/google/spanner/v1/location.proto",
|
|
9
10
|
"../../protos/google/spanner/v1/mutation.proto",
|
|
10
11
|
"../../protos/google/spanner/v1/query_plan.proto",
|
|
11
12
|
"../../protos/google/spanner/v1/result_set.proto",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"../../protos/google/spanner/v1/change_stream.proto",
|
|
3
3
|
"../../protos/google/spanner/v1/commit_response.proto",
|
|
4
4
|
"../../protos/google/spanner/v1/keys.proto",
|
|
5
|
+
"../../protos/google/spanner/v1/location.proto",
|
|
5
6
|
"../../protos/google/spanner/v1/mutation.proto",
|
|
6
7
|
"../../protos/google/spanner/v1/query_plan.proto",
|
|
7
8
|
"../../protos/google/spanner/v1/result_set.proto",
|
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.
|
|
4
|
+
"version": "8.5.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Google Inc.",
|
|
7
7
|
"engines": {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"events-intercept": "^2.0.0",
|
|
77
77
|
"extend": "^3.0.2",
|
|
78
78
|
"google-auth-library": "^10.0.0-rc.1",
|
|
79
|
-
"google-gax": "5.0.
|
|
79
|
+
"google-gax": "5.0.6",
|
|
80
80
|
"grpc-gcp": "^1.0.1",
|
|
81
81
|
"lodash.snakecase": "^4.1.1",
|
|
82
82
|
"merge-stream": "^2.0.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"@types/ncp": "^2.0.8",
|
|
107
107
|
"@types/proxyquire": "^1.3.31",
|
|
108
108
|
"@types/request": "^2.48.12",
|
|
109
|
-
"@types/sinon": "^
|
|
109
|
+
"@types/sinon": "^21.0.0",
|
|
110
110
|
"@types/through2": "^2.0.41",
|
|
111
111
|
"binary-search-bounds": "^2.0.5",
|
|
112
112
|
"c8": "^10.1.3",
|