@google-cloud/spanner 7.17.0 → 7.18.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 +14 -0
- package/package.json +1 -1
- package/build/protos/google/spanner/admin/database/v1/backup.proto +0 -757
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +0 -230
- package/build/protos/google/spanner/admin/database/v1/common.proto +0 -132
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +0 -1209
- package/build/protos/google/spanner/admin/instance/v1/common.proto +0 -63
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +0 -1983
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +0 -1520
- package/build/protos/google/spanner/v1/commit_response.proto +0 -59
- package/build/protos/google/spanner/v1/keys.proto +0 -163
- package/build/protos/google/spanner/v1/mutation.proto +0 -107
- package/build/protos/google/spanner/v1/query_plan.proto +0 -128
- package/build/protos/google/spanner/v1/result_set.proto +0 -237
- package/build/protos/google/spanner/v1/spanner.proto +0 -1389
- package/build/protos/google/spanner/v1/transaction.proto +0 -575
- package/build/protos/google/spanner/v1/type.proto +0 -210
- package/build/protos/protos.d.ts +0 -38999
- package/build/protos/protos.js +0 -99538
- package/build/protos/protos.json +0 -10182
- package/build/src/backup.d.ts +0 -349
- package/build/src/backup.js +0 -246
- package/build/src/batch-transaction.d.ts +0 -247
- package/build/src/batch-transaction.js +0 -384
- package/build/src/codec.d.ts +0 -362
- package/build/src/codec.js +0 -791
- package/build/src/common-grpc/service-object.d.ts +0 -80
- package/build/src/common-grpc/service-object.js +0 -101
- package/build/src/common-grpc/service.d.ts +0 -445
- package/build/src/common-grpc/service.js +0 -826
- package/build/src/common.d.ts +0 -66
- package/build/src/common.js +0 -54
- package/build/src/database.d.ts +0 -2104
- package/build/src/database.js +0 -1655
- package/build/src/extra_proto_list.json +0 -1
- package/build/src/helper.d.ts +0 -45
- package/build/src/helper.js +0 -71
- package/build/src/index.d.ts +0 -1195
- package/build/src/index.js +0 -1060
- package/build/src/instance-config.d.ts +0 -295
- package/build/src/instance-config.js +0 -216
- package/build/src/instance.d.ts +0 -833
- package/build/src/instance.js +0 -781
- package/build/src/instrument.d.ts +0 -87
- package/build/src/instrument.js +0 -217
- package/build/src/multiplexed-session.d.ts +0 -136
- package/build/src/multiplexed-session.js +0 -197
- package/build/src/partial-result-stream.d.ts +0 -253
- package/build/src/partial-result-stream.js +0 -400
- package/build/src/session-factory.d.ts +0 -101
- package/build/src/session-factory.js +0 -93
- package/build/src/session-pool.d.ts +0 -471
- package/build/src/session-pool.js +0 -754
- package/build/src/session.d.ts +0 -259
- package/build/src/session.js +0 -348
- package/build/src/spanner_grpc_config.json +0 -92
- package/build/src/table.d.ts +0 -831
- package/build/src/table.js +0 -277
- package/build/src/transaction-runner.d.ts +0 -185
- package/build/src/transaction-runner.js +0 -282
- package/build/src/transaction.d.ts +0 -1691
- package/build/src/transaction.js +0 -2004
- package/build/src/v1/database_admin_client.d.ts +0 -2301
- package/build/src/v1/database_admin_client.js +0 -2286
- package/build/src/v1/database_admin_client_config.json +0 -160
- package/build/src/v1/database_admin_proto_list.json +0 -6
- package/build/src/v1/gapic_metadata.json +0 -27
- package/build/src/v1/index.d.ts +0 -4
- package/build/src/v1/index.js +0 -29
- package/build/src/v1/instance_admin_client.d.ts +0 -1982
- package/build/src/v1/instance_admin_client.js +0 -1766
- package/build/src/v1/instance_admin_client_config.json +0 -129
- package/build/src/v1/instance_admin_proto_list.json +0 -4
- package/build/src/v1/spanner_client.d.ts +0 -1250
- package/build/src/v1/spanner_client.js +0 -1086
- package/build/src/v1/spanner_client_config.json +0 -119
- package/build/src/v1/spanner_executor_proxy_client.d.ts +0 -418
- package/build/src/v1/spanner_executor_proxy_client.js +0 -706
- package/build/src/v1/spanner_executor_proxy_client_config.json +0 -30
- package/build/src/v1/spanner_executor_proxy_proto_list.json +0 -14
- package/build/src/v1/spanner_proto_list.json +0 -10
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2024 Google LLC. All Rights Reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Database, Session, Transaction } from '.';
|
|
17
|
-
import { MultiplexedSessionInterface } from './multiplexed-session';
|
|
18
|
-
import { SessionPoolInterface, SessionPoolOptions } from './session-pool';
|
|
19
|
-
import { SessionPoolConstructor } from './database';
|
|
20
|
-
declare const common: any;
|
|
21
|
-
/**
|
|
22
|
-
* @callback GetSessionCallback
|
|
23
|
-
* @param {?Error} error Request error, if any.
|
|
24
|
-
* @param {Session} session The read-write session.
|
|
25
|
-
* @param {Transaction} transaction The transaction object.
|
|
26
|
-
*/
|
|
27
|
-
export interface GetSessionCallback {
|
|
28
|
-
(err: Error | null, session?: Session | null, transaction?: Transaction | null): void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Interface for implementing session-factory logic.
|
|
32
|
-
*
|
|
33
|
-
* @interface SessionFactoryInterface
|
|
34
|
-
*/
|
|
35
|
-
export interface SessionFactoryInterface {
|
|
36
|
-
/**
|
|
37
|
-
* When called returns a session.
|
|
38
|
-
*
|
|
39
|
-
* @name SessionFactoryInterface#getSession
|
|
40
|
-
* @param {GetSessionCallback} callback The callback function.
|
|
41
|
-
*/
|
|
42
|
-
getSession(callback: GetSessionCallback): void;
|
|
43
|
-
/**
|
|
44
|
-
* When called returns the pool object.
|
|
45
|
-
*
|
|
46
|
-
* @name SessionFactoryInterface#getPool
|
|
47
|
-
*/
|
|
48
|
-
getPool(): SessionPoolInterface;
|
|
49
|
-
/**
|
|
50
|
-
* To be called when releasing a session.
|
|
51
|
-
*
|
|
52
|
-
* @name SessionFactoryInterface#release
|
|
53
|
-
* @param {Session} session The session to be released.
|
|
54
|
-
*/
|
|
55
|
-
release(session: Session): void;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Creates a SessionFactory object to manage the creation of
|
|
59
|
-
* session-pool and multiplexed session.
|
|
60
|
-
*
|
|
61
|
-
* @class
|
|
62
|
-
*
|
|
63
|
-
* @param {Database} database Database object.
|
|
64
|
-
* @param {String} name Name of the database.
|
|
65
|
-
* @param {SessionPoolOptions|SessionPoolInterface} options Session pool
|
|
66
|
-
* configuration options or custom pool inteface.
|
|
67
|
-
*/
|
|
68
|
-
export declare class SessionFactory extends common.GrpcServiceObject implements SessionFactoryInterface {
|
|
69
|
-
static [x: string]: any;
|
|
70
|
-
multiplexedSession_: MultiplexedSessionInterface;
|
|
71
|
-
pool_: SessionPoolInterface;
|
|
72
|
-
constructor(database: Database, name: String, poolOptions?: SessionPoolConstructor | SessionPoolOptions);
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves a session, either a regular session or a multiplexed session, based on the environment variable configuration.
|
|
75
|
-
*
|
|
76
|
-
* If the environment variable `GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS` is set to `true`, the method will attempt to
|
|
77
|
-
* retrieve a multiplexed session. Otherwise, it will retrieve a session from the regular pool.
|
|
78
|
-
*
|
|
79
|
-
* @param {GetSessionCallback} callback The callback function.
|
|
80
|
-
*/
|
|
81
|
-
getSession(callback: GetSessionCallback): void;
|
|
82
|
-
/**
|
|
83
|
-
* Returns the regular session pool object.
|
|
84
|
-
*
|
|
85
|
-
* @returns {SessionPoolInterface} The session pool used by current instance.
|
|
86
|
-
*/
|
|
87
|
-
getPool(): SessionPoolInterface;
|
|
88
|
-
/**
|
|
89
|
-
* Releases a session back to the session pool.
|
|
90
|
-
*
|
|
91
|
-
* This method returns a session to the pool after it is no longer needed.
|
|
92
|
-
* It is a no-op for multiplexed sessions.
|
|
93
|
-
*
|
|
94
|
-
* @param {Session} session - The session to be released. This should be an instance of `Session` that was
|
|
95
|
-
* previously acquired from the session pool.
|
|
96
|
-
*
|
|
97
|
-
* @throws {Error} If the session is invalid or cannot be released.
|
|
98
|
-
*/
|
|
99
|
-
release(session: Session): void;
|
|
100
|
-
}
|
|
101
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright 2024 Google LLC. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.SessionFactory = void 0;
|
|
19
|
-
const multiplexed_session_1 = require("./multiplexed-session");
|
|
20
|
-
const session_pool_1 = require("./session-pool");
|
|
21
|
-
const common = require('./common-grpc/service-object');
|
|
22
|
-
/**
|
|
23
|
-
* Creates a SessionFactory object to manage the creation of
|
|
24
|
-
* session-pool and multiplexed session.
|
|
25
|
-
*
|
|
26
|
-
* @class
|
|
27
|
-
*
|
|
28
|
-
* @param {Database} database Database object.
|
|
29
|
-
* @param {String} name Name of the database.
|
|
30
|
-
* @param {SessionPoolOptions|SessionPoolInterface} options Session pool
|
|
31
|
-
* configuration options or custom pool inteface.
|
|
32
|
-
*/
|
|
33
|
-
class SessionFactory extends common.GrpcServiceObject {
|
|
34
|
-
constructor(database, name, poolOptions) {
|
|
35
|
-
super({
|
|
36
|
-
parent: database,
|
|
37
|
-
id: name,
|
|
38
|
-
});
|
|
39
|
-
this.pool_ =
|
|
40
|
-
typeof poolOptions === 'function'
|
|
41
|
-
? new poolOptions(database, null)
|
|
42
|
-
: new session_pool_1.SessionPool(database, poolOptions);
|
|
43
|
-
this.pool_.on('error', this.emit.bind(database, 'error'));
|
|
44
|
-
this.pool_.open();
|
|
45
|
-
this.multiplexedSession_ = new multiplexed_session_1.MultiplexedSession(database);
|
|
46
|
-
// Multiplexed sessions should only be created if its enabled.
|
|
47
|
-
if (this.multiplexedSession_.isMultiplexedEnabled) {
|
|
48
|
-
this.multiplexedSession_.on('error', this.emit.bind(database, 'error'));
|
|
49
|
-
this.multiplexedSession_.createSession();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves a session, either a regular session or a multiplexed session, based on the environment variable configuration.
|
|
54
|
-
*
|
|
55
|
-
* If the environment variable `GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS` is set to `true`, the method will attempt to
|
|
56
|
-
* retrieve a multiplexed session. Otherwise, it will retrieve a session from the regular pool.
|
|
57
|
-
*
|
|
58
|
-
* @param {GetSessionCallback} callback The callback function.
|
|
59
|
-
*/
|
|
60
|
-
getSession(callback) {
|
|
61
|
-
const sessionHandler = this.multiplexedSession_
|
|
62
|
-
.isMultiplexedEnabled
|
|
63
|
-
? this.multiplexedSession_
|
|
64
|
-
: this.pool_;
|
|
65
|
-
sessionHandler.getSession((err, session) => callback(err, session));
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Returns the regular session pool object.
|
|
69
|
-
*
|
|
70
|
-
* @returns {SessionPoolInterface} The session pool used by current instance.
|
|
71
|
-
*/
|
|
72
|
-
getPool() {
|
|
73
|
-
return this.pool_;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Releases a session back to the session pool.
|
|
77
|
-
*
|
|
78
|
-
* This method returns a session to the pool after it is no longer needed.
|
|
79
|
-
* It is a no-op for multiplexed sessions.
|
|
80
|
-
*
|
|
81
|
-
* @param {Session} session - The session to be released. This should be an instance of `Session` that was
|
|
82
|
-
* previously acquired from the session pool.
|
|
83
|
-
*
|
|
84
|
-
* @throws {Error} If the session is invalid or cannot be released.
|
|
85
|
-
*/
|
|
86
|
-
release(session) {
|
|
87
|
-
if (!this.multiplexedSession_.isMultiplexedEnabled) {
|
|
88
|
-
this.pool_.release(session);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.SessionFactory = SessionFactory;
|
|
93
|
-
//# sourceMappingURL=session-factory.js.map
|
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright 2016 Google Inc. All Rights Reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { EventEmitter } from 'events';
|
|
17
|
-
import PQueue from 'p-queue';
|
|
18
|
-
import { Database } from './database';
|
|
19
|
-
import { Session } from './session';
|
|
20
|
-
import { Transaction } from './transaction';
|
|
21
|
-
import { NormalCallback } from './common';
|
|
22
|
-
import { GoogleError, grpc } from 'google-gax';
|
|
23
|
-
import trace = require('stack-trace');
|
|
24
|
-
import { ObservabilityOptions } from './instrument';
|
|
25
|
-
import { GetSessionCallback } from './session-factory';
|
|
26
|
-
/**
|
|
27
|
-
* @callback SessionPoolCloseCallback
|
|
28
|
-
* @param {?Error} error Closing error, if any.
|
|
29
|
-
*/
|
|
30
|
-
export interface SessionPoolCloseCallback {
|
|
31
|
-
(error?: SessionLeakError): void;
|
|
32
|
-
}
|
|
33
|
-
/** @deprecated. Use GetSessionCallback instead. */
|
|
34
|
-
export type GetReadSessionCallback = NormalCallback<Session>;
|
|
35
|
-
/** @deprecated. Use GetSessionCallback instead. */
|
|
36
|
-
export interface GetWriteSessionCallback {
|
|
37
|
-
(err: Error | null, session?: Session | null, transaction?: Transaction | null): void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Interface for implementing custom session pooling logic, it should extend the
|
|
41
|
-
* {@link https://nodejs.org/api/events.html|EventEmitter} class and emit any
|
|
42
|
-
* asynchronous errors via an error event.
|
|
43
|
-
*
|
|
44
|
-
* @interface SessionPoolInterface
|
|
45
|
-
* @extends external:{@link https://nodejs.org/api/events.html|EventEmitter}
|
|
46
|
-
*/
|
|
47
|
-
/**
|
|
48
|
-
* @constructs SessionPoolInterface
|
|
49
|
-
* @param {Database} database The database to create a pool for.
|
|
50
|
-
*/
|
|
51
|
-
export interface SessionPoolInterface extends EventEmitter {
|
|
52
|
-
/**
|
|
53
|
-
* Will be called via {@link Database#close}. Indicates that the pool should
|
|
54
|
-
* perform any necessary teardown actions to its resources.
|
|
55
|
-
*
|
|
56
|
-
* @name SessionPoolInterface#close
|
|
57
|
-
* @param {SessionPoolCloseCallback} callback The callback function.
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* Will be called by the Database object, should be used to start creating
|
|
61
|
-
* sessions/etc.
|
|
62
|
-
*
|
|
63
|
-
* @name SessionPoolInterface#open
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* When called returns a session.
|
|
67
|
-
*
|
|
68
|
-
* @name SessionPoolInterface#getSession
|
|
69
|
-
* @param {GetSessionCallback} callback The callback function.
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* When called returns a session.
|
|
73
|
-
*
|
|
74
|
-
* @deprecated Use getSession instead.
|
|
75
|
-
* @name SessionPoolInterface#getReadSession
|
|
76
|
-
* @param {GetReadSessionCallback} callback The callback function.
|
|
77
|
-
*/
|
|
78
|
-
/**
|
|
79
|
-
* When called returns a session.
|
|
80
|
-
*
|
|
81
|
-
* @deprecated Use getSession instead.
|
|
82
|
-
* @name SessionPoolInterface#getWriteSession
|
|
83
|
-
* @param {GetWriteSessionCallback} callback The callback function.
|
|
84
|
-
*/
|
|
85
|
-
/**
|
|
86
|
-
* To be called when releasing a session back into the pool.
|
|
87
|
-
*
|
|
88
|
-
* @name SessionPoolInterface#release
|
|
89
|
-
* @param {Session} session The session to be released.
|
|
90
|
-
*/
|
|
91
|
-
close(callback: SessionPoolCloseCallback): void;
|
|
92
|
-
open(): void;
|
|
93
|
-
getSession(callback: GetSessionCallback): void;
|
|
94
|
-
getReadSession(callback: GetReadSessionCallback): void;
|
|
95
|
-
getWriteSession(callback: GetWriteSessionCallback): void;
|
|
96
|
-
release(session: Session): void;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Session pool configuration options.
|
|
100
|
-
*
|
|
101
|
-
* @typedef {object} SessionPoolOptions
|
|
102
|
-
* @property {number} [acquireTimeout=Infinity] Time in milliseconds before
|
|
103
|
-
* giving up trying to acquire a session. If the specified value is
|
|
104
|
-
* `Infinity`, a timeout will not occur.
|
|
105
|
-
* @property {number} [concurrency=Infinity] How many concurrent requests the pool is
|
|
106
|
-
* allowed to make.
|
|
107
|
-
* @property {boolean} [fail=false] If set to true, an error will be thrown when
|
|
108
|
-
* there are no available sessions for a request.
|
|
109
|
-
* @property {number} [idlesAfter=10] How long until a resource becomes idle, in
|
|
110
|
-
* minutes.
|
|
111
|
-
* @property {number} [keepAlive=30] How often to ping idle sessions, in
|
|
112
|
-
* minutes. Must be less than 1 hour.
|
|
113
|
-
* @property {Object<string, string>} [labels] Labels to apply to any session
|
|
114
|
-
* created by the pool.
|
|
115
|
-
* @property {number} [max=100] Maximum number of resources to create at any
|
|
116
|
-
* given time.
|
|
117
|
-
* @property {number} [maxIdle=1] Maximum number of idle resources to keep in
|
|
118
|
-
* the pool at any given time.
|
|
119
|
-
* @property {number} [min=25] Minimum number of resources to keep in the pool at
|
|
120
|
-
* any given time.
|
|
121
|
-
* @property {number} [writes=0.0]. Deprecated.
|
|
122
|
-
* @property {number} [incStep=25] The number of new sessions to create when at
|
|
123
|
-
* least one more session is needed.
|
|
124
|
-
*/
|
|
125
|
-
export interface SessionPoolOptions {
|
|
126
|
-
acquireTimeout?: number;
|
|
127
|
-
concurrency?: number;
|
|
128
|
-
fail?: boolean;
|
|
129
|
-
idlesAfter?: number;
|
|
130
|
-
keepAlive?: number;
|
|
131
|
-
labels?: {
|
|
132
|
-
[label: string]: string;
|
|
133
|
-
};
|
|
134
|
-
max?: number;
|
|
135
|
-
maxIdle?: number;
|
|
136
|
-
min?: number;
|
|
137
|
-
/**
|
|
138
|
-
* @deprecated. Starting from v6.5.0 the same session can be reused for
|
|
139
|
-
* different types of transactions.
|
|
140
|
-
*/
|
|
141
|
-
writes?: number;
|
|
142
|
-
incStep?: number;
|
|
143
|
-
databaseRole?: string | null;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Error to be thrown when attempting to release unknown resources.
|
|
147
|
-
*
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
export declare class ReleaseError extends GoogleError {
|
|
151
|
-
resource: unknown;
|
|
152
|
-
constructor(resource: unknown);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Error to be thrown when session leaks are detected.
|
|
156
|
-
*
|
|
157
|
-
* @private
|
|
158
|
-
*/
|
|
159
|
-
export declare class SessionLeakError extends GoogleError {
|
|
160
|
-
messages: string[];
|
|
161
|
-
constructor(leaks: string[]);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Error to be thrown when the session pool is exhausted.
|
|
165
|
-
*/
|
|
166
|
-
export declare class SessionPoolExhaustedError extends GoogleError {
|
|
167
|
-
messages: string[];
|
|
168
|
-
constructor(leaks: string[]);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Checks whether the given error is a 'Session not found' error.
|
|
172
|
-
* @param error the error to check
|
|
173
|
-
* @return true if the error is a 'Session not found' error, and otherwise false.
|
|
174
|
-
*/
|
|
175
|
-
export declare function isSessionNotFoundError(error: grpc.ServiceError | undefined): boolean;
|
|
176
|
-
interface SessionInventory {
|
|
177
|
-
sessions: Session[];
|
|
178
|
-
borrowed: Set<Session>;
|
|
179
|
-
}
|
|
180
|
-
/** @deprecated. */
|
|
181
|
-
export interface CreateSessionsOptions {
|
|
182
|
-
writes?: number;
|
|
183
|
-
reads?: number;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Class used to manage connections to Spanner.
|
|
187
|
-
*
|
|
188
|
-
* **You don't need to use this class directly, connections will be handled for
|
|
189
|
-
* you.**
|
|
190
|
-
*
|
|
191
|
-
* @class
|
|
192
|
-
* @extends {EventEmitter}
|
|
193
|
-
*/
|
|
194
|
-
export declare class SessionPool extends EventEmitter implements SessionPoolInterface {
|
|
195
|
-
database: Database;
|
|
196
|
-
isOpen: boolean;
|
|
197
|
-
options: SessionPoolOptions;
|
|
198
|
-
_acquires: PQueue;
|
|
199
|
-
_evictHandle: NodeJS.Timer;
|
|
200
|
-
_inventory: SessionInventory;
|
|
201
|
-
_onClose: Promise<void>;
|
|
202
|
-
_pending: number;
|
|
203
|
-
_waiters: number;
|
|
204
|
-
_pingHandle: NodeJS.Timer;
|
|
205
|
-
_requests: PQueue;
|
|
206
|
-
_traces: Map<string, trace.StackFrame[]>;
|
|
207
|
-
_observabilityOptions?: ObservabilityOptions;
|
|
208
|
-
/**
|
|
209
|
-
* Formats stack trace objects into Node-like stack trace.
|
|
210
|
-
*
|
|
211
|
-
* @param {object[]} trace The trace object.
|
|
212
|
-
* @return {string}
|
|
213
|
-
*/
|
|
214
|
-
static formatTrace(frames: trace.StackFrame[]): string;
|
|
215
|
-
/**
|
|
216
|
-
* Total number of available sessions.
|
|
217
|
-
* @type {number}
|
|
218
|
-
*/
|
|
219
|
-
get available(): number;
|
|
220
|
-
/** @deprecated Starting from v6.5.0 the same session can be reused for
|
|
221
|
-
* different types of transactions.
|
|
222
|
-
*/
|
|
223
|
-
get currentWriteFraction(): number;
|
|
224
|
-
/**
|
|
225
|
-
* Total number of borrowed sessions.
|
|
226
|
-
* @type {number}
|
|
227
|
-
*/
|
|
228
|
-
get borrowed(): number;
|
|
229
|
-
/**
|
|
230
|
-
* Flag to determine if Pool is full.
|
|
231
|
-
* @type {boolean}
|
|
232
|
-
*/
|
|
233
|
-
get isFull(): boolean;
|
|
234
|
-
/** @deprecated Use `size()` instead. */
|
|
235
|
-
get reads(): number;
|
|
236
|
-
/**
|
|
237
|
-
* Total size of pool.
|
|
238
|
-
* @type {number}
|
|
239
|
-
*/
|
|
240
|
-
get size(): number;
|
|
241
|
-
/** @deprecated Use `size()` instead. */
|
|
242
|
-
get writes(): number;
|
|
243
|
-
/** @deprecated Starting v6.5.0 the pending prepare state is obsolete. */
|
|
244
|
-
get pendingPrepare(): number;
|
|
245
|
-
/**
|
|
246
|
-
* Number of sessions being created or prepared for a read/write transaction.
|
|
247
|
-
* @type {number}
|
|
248
|
-
*/
|
|
249
|
-
get totalPending(): number;
|
|
250
|
-
/** @deprecated Use totalWaiters instead. */
|
|
251
|
-
get numReadWaiters(): number;
|
|
252
|
-
/** @deprecated Use totalWaiters instead. */
|
|
253
|
-
get numWriteWaiters(): number;
|
|
254
|
-
/**
|
|
255
|
-
* Sum of read and write waiters.
|
|
256
|
-
* @type {number}
|
|
257
|
-
*/
|
|
258
|
-
get totalWaiters(): number;
|
|
259
|
-
/**
|
|
260
|
-
* @constructor
|
|
261
|
-
* @param {Database} database The DB instance.
|
|
262
|
-
* @param {SessionPoolOptions} [options] Configuration options.
|
|
263
|
-
*/
|
|
264
|
-
constructor(database: Database, options?: SessionPoolOptions);
|
|
265
|
-
/**
|
|
266
|
-
* Closes and the pool.
|
|
267
|
-
*
|
|
268
|
-
* @emits SessionPool#close
|
|
269
|
-
* @param {SessionPoolCloseCallback} callback The callback function.
|
|
270
|
-
*/
|
|
271
|
-
close(callback: SessionPoolCloseCallback): void;
|
|
272
|
-
/**
|
|
273
|
-
* Retrieve a read session.
|
|
274
|
-
*
|
|
275
|
-
* @deprecated Use getSession instead.
|
|
276
|
-
* @param {GetReadSessionCallback} callback The callback function.
|
|
277
|
-
*/
|
|
278
|
-
getReadSession(callback: GetReadSessionCallback): void;
|
|
279
|
-
/**
|
|
280
|
-
* Retrieve a read/write session.
|
|
281
|
-
*
|
|
282
|
-
* @deprecated use getSession instead.
|
|
283
|
-
* @param {GetWriteSessionCallback} callback The callback function.
|
|
284
|
-
*/
|
|
285
|
-
getWriteSession(callback: GetWriteSessionCallback): void;
|
|
286
|
-
/**
|
|
287
|
-
* Retrieve a session.
|
|
288
|
-
*
|
|
289
|
-
* @param {GetSessionCallback} callback The callback function.
|
|
290
|
-
*/
|
|
291
|
-
getSession(callback: GetSessionCallback): void;
|
|
292
|
-
/**
|
|
293
|
-
* Opens the pool, filling it to the configured number of read and write
|
|
294
|
-
* sessions.
|
|
295
|
-
*
|
|
296
|
-
* @emits SessionPool#open
|
|
297
|
-
* @return {Promise}
|
|
298
|
-
*/
|
|
299
|
-
open(): void;
|
|
300
|
-
/**
|
|
301
|
-
* Releases session back into the pool.
|
|
302
|
-
*
|
|
303
|
-
* @throws {Error} For unknown sessions.
|
|
304
|
-
* @emits SessionPool#available
|
|
305
|
-
* @emits SessionPool#error
|
|
306
|
-
* @fires SessionPool#session-available
|
|
307
|
-
* @fires @deprecated SessionPool#readonly-available
|
|
308
|
-
* @fires @deprecated SessionPool#readwrite-available
|
|
309
|
-
* @param {Session} session The session to release.
|
|
310
|
-
*/
|
|
311
|
-
release(session: Session): void;
|
|
312
|
-
/**
|
|
313
|
-
* Attempts to borrow a session from the pool.
|
|
314
|
-
*
|
|
315
|
-
* @private
|
|
316
|
-
*
|
|
317
|
-
* @returns {Promise<Session>}
|
|
318
|
-
*/
|
|
319
|
-
_acquire(): Promise<Session>;
|
|
320
|
-
/**
|
|
321
|
-
* Moves a session into the borrowed group.
|
|
322
|
-
*
|
|
323
|
-
* @private
|
|
324
|
-
*
|
|
325
|
-
* @param {Session} session The session object.
|
|
326
|
-
*/
|
|
327
|
-
_borrow(session: Session): void;
|
|
328
|
-
/**
|
|
329
|
-
* Borrows the first session from the inventory.
|
|
330
|
-
*
|
|
331
|
-
* @private
|
|
332
|
-
*
|
|
333
|
-
* @return {Session}
|
|
334
|
-
*/
|
|
335
|
-
_borrowFrom(): Session;
|
|
336
|
-
/**
|
|
337
|
-
* Grabs the next available session.
|
|
338
|
-
*
|
|
339
|
-
* @private
|
|
340
|
-
*
|
|
341
|
-
* @returns {Promise<Session>}
|
|
342
|
-
*/
|
|
343
|
-
_borrowNextAvailableSession(): Session;
|
|
344
|
-
/**
|
|
345
|
-
* Attempts to create a single session.
|
|
346
|
-
*
|
|
347
|
-
* @private
|
|
348
|
-
*
|
|
349
|
-
* @returns {Promise}
|
|
350
|
-
*/
|
|
351
|
-
_createSession(): Promise<void>;
|
|
352
|
-
/**
|
|
353
|
-
* Batch creates sessions.
|
|
354
|
-
*
|
|
355
|
-
* @private
|
|
356
|
-
*
|
|
357
|
-
* @param {number} [amount] Config specifying how many sessions to create.
|
|
358
|
-
* @returns {Promise}
|
|
359
|
-
* @emits SessionPool#createError
|
|
360
|
-
*/
|
|
361
|
-
_createSessions(amount: number): Promise<void>;
|
|
362
|
-
/**
|
|
363
|
-
* Attempts to delete a session, optionally creating a new one of the same
|
|
364
|
-
* type if the pool is still open and we're under the configured min value.
|
|
365
|
-
*
|
|
366
|
-
* @private
|
|
367
|
-
*
|
|
368
|
-
* @fires SessionPool#error
|
|
369
|
-
* @param {Session} session The session to delete.
|
|
370
|
-
* @returns {Promise}
|
|
371
|
-
*/
|
|
372
|
-
_destroy(session: Session): Promise<void>;
|
|
373
|
-
/**
|
|
374
|
-
* Deletes idle sessions that exceed the maxIdle configuration.
|
|
375
|
-
*
|
|
376
|
-
* @private
|
|
377
|
-
*/
|
|
378
|
-
_evictIdleSessions(): void;
|
|
379
|
-
/**
|
|
380
|
-
* Fills the pool with the minimum number of sessions.
|
|
381
|
-
*
|
|
382
|
-
* @return {Promise}
|
|
383
|
-
*/
|
|
384
|
-
_fill(): Promise<void>;
|
|
385
|
-
/**
|
|
386
|
-
* Retrieves a list of all the idle sessions.
|
|
387
|
-
*
|
|
388
|
-
* @private
|
|
389
|
-
*
|
|
390
|
-
* @returns {Session[]}
|
|
391
|
-
*/
|
|
392
|
-
_getIdleSessions(): Session[];
|
|
393
|
-
/**
|
|
394
|
-
* Returns stack traces for sessions that have not been released.
|
|
395
|
-
*
|
|
396
|
-
* @return {string[]}
|
|
397
|
-
*/
|
|
398
|
-
_getLeaks(): string[];
|
|
399
|
-
/**
|
|
400
|
-
* Returns true if the pool has a usable session.
|
|
401
|
-
* @private
|
|
402
|
-
*/
|
|
403
|
-
_hasSessionUsableFor(): boolean;
|
|
404
|
-
/**
|
|
405
|
-
* Attempts to get a session.
|
|
406
|
-
*
|
|
407
|
-
* @private
|
|
408
|
-
*
|
|
409
|
-
* @param {number} startTime Timestamp to use when determining timeouts.
|
|
410
|
-
* @returns {Promise<Session>}
|
|
411
|
-
*/
|
|
412
|
-
_getSession(startTime: number): Promise<Session>;
|
|
413
|
-
/**
|
|
414
|
-
* Checks to see whether or not session is expired.
|
|
415
|
-
*
|
|
416
|
-
* @param {Session} session The session to check.
|
|
417
|
-
* @returns {boolean}
|
|
418
|
-
*/
|
|
419
|
-
_isValidSession(session: Session): boolean;
|
|
420
|
-
/**
|
|
421
|
-
* Pings an individual session.
|
|
422
|
-
*
|
|
423
|
-
* @private
|
|
424
|
-
*
|
|
425
|
-
* @param {Session} session The session to ping.
|
|
426
|
-
* @returns {Promise}
|
|
427
|
-
*/
|
|
428
|
-
_ping(session: Session): Promise<void>;
|
|
429
|
-
/**
|
|
430
|
-
* Makes a keep alive request to all the idle sessions.
|
|
431
|
-
*
|
|
432
|
-
* @private
|
|
433
|
-
*
|
|
434
|
-
* @returns {Promise}
|
|
435
|
-
*/
|
|
436
|
-
_pingIdleSessions(): Promise<void>;
|
|
437
|
-
/**
|
|
438
|
-
* Creates a transaction for a session.
|
|
439
|
-
*
|
|
440
|
-
* @private
|
|
441
|
-
*
|
|
442
|
-
* @param {Session} session The session object.
|
|
443
|
-
* @param {object} options The transaction options.
|
|
444
|
-
*/
|
|
445
|
-
_prepareTransaction(session: Session): void;
|
|
446
|
-
/**
|
|
447
|
-
* Releases a session back into the pool.
|
|
448
|
-
*
|
|
449
|
-
* @private
|
|
450
|
-
*
|
|
451
|
-
* @fires SessionPool#available
|
|
452
|
-
* @fires SessionPool#session-available
|
|
453
|
-
* @fires @deprecated SessionPool#readonly-available
|
|
454
|
-
* @fires @deprecated SessionPool#readwrite-available
|
|
455
|
-
* @param {Session} session The session object.
|
|
456
|
-
*/
|
|
457
|
-
_release(session: Session): void;
|
|
458
|
-
/**
|
|
459
|
-
* Starts housekeeping (pinging/evicting) of idle sessions.
|
|
460
|
-
*
|
|
461
|
-
* @private
|
|
462
|
-
*/
|
|
463
|
-
_startHouseKeeping(): void;
|
|
464
|
-
/**
|
|
465
|
-
* Stops housekeeping.
|
|
466
|
-
*
|
|
467
|
-
* @private
|
|
468
|
-
*/
|
|
469
|
-
_stopHouseKeeping(): void;
|
|
470
|
-
}
|
|
471
|
-
export {};
|