Skip to content

Commit bf3f72e

Browse files
authored
chore: support for option multiplexed in create session (#2175)
This PR contains addition of an option `multiplexed` enabling which while calling createSession method will create a multiplexed session instead of regular session.
1 parent 19f137c commit bf3f72e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/database.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export interface CreateSessionOptions {
247247
labels?: {[k: string]: string} | null;
248248
databaseRole?: string | null;
249249
gaxOptions?: CallOptions;
250+
multiplexed?: boolean;
250251
}
251252

252253
export interface GetIamPolicyOptions {
@@ -981,6 +982,10 @@ class Database extends common.GrpcServiceObject {
981982
reqOpts.session.labels = options.labels;
982983
}
983984

985+
if (options.multiplexed) {
986+
reqOpts.session.multiplexed = options.multiplexed;
987+
}
988+
984989
reqOpts.session.creatorRole =
985990
options.databaseRole || this.databaseRole || null;
986991

test/database.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,23 @@ describe('Database', () => {
21772177
database.createSession(databaseRole, assert.ifError);
21782178
});
21792179

2180+
it('should send multiplexed correctly', done => {
2181+
const multiplexed = {multiplexed: true};
2182+
const options = {a: 'b', multiplexed};
2183+
const originalOptions = extend(true, {}, options);
2184+
2185+
database.request = config => {
2186+
assert.deepStrictEqual(
2187+
config.reqOpts.session.multiplexed,
2188+
multiplexed.multiplexed
2189+
);
2190+
assert.deepStrictEqual(options, originalOptions);
2191+
done();
2192+
};
2193+
2194+
database.createSession(multiplexed, assert.ifError);
2195+
});
2196+
21802197
describe('error', () => {
21812198
const ERROR = new Error('Error.');
21822199
const API_RESPONSE = {};

0 commit comments

Comments
 (0)