Skip to content

Commit aff15d1

Browse files
renovate[bot]JustinBeckwith
authored andcommitted
fix(deps): update dependency @google-cloud/common-grpc to ^0.10.0 (#504)
1 parent 7fc5206 commit aff15d1

File tree

7 files changed

+30
-22
lines changed

7 files changed

+30
-22
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"presystem-test": "npm run compile"
4848
},
4949
"dependencies": {
50-
"@google-cloud/common-grpc": "^0.9.2",
50+
"@google-cloud/common-grpc": "^0.10.0",
5151
"@google-cloud/paginator": "^0.1.0",
5252
"@google-cloud/projectify": "^0.3.0",
5353
"@google-cloud/promisify": "^0.3.0",

src/database.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {ApiError, DeleteCallback, ExistsCallback, GetMetadataCallback, Metadata, ServiceObjectConfig} from '@google-cloud/common';
17+
import {ApiError, DeleteCallback, ExistsCallback, Metadata, MetadataCallback, ServiceObjectConfig} from '@google-cloud/common';
1818
import {ServiceObject} from '@google-cloud/common-grpc';
1919
import {promisifyAll} from '@google-cloud/promisify';
2020
import * as arrify from 'arrify';
@@ -59,6 +59,8 @@ export interface DatabaseCallback {
5959
* const database = instance.database('my-database');
6060
*/
6161
class Database extends ServiceObject {
62+
formattedName_: string;
63+
pool_: SessionPool;
6264
constructor(instance: Instance, name: string, poolOptions?) {
6365
const methods = {
6466
/**
@@ -659,8 +661,8 @@ class Database extends ServiceObject {
659661
* });
660662
*/
661663
getMetadata(): Promise<Metadata>;
662-
getMetadata(callback: GetMetadataCallback): void;
663-
getMetadata(callback?: GetMetadataCallback): void|Promise<Metadata> {
664+
getMetadata(callback: MetadataCallback): void;
665+
getMetadata(callback?: MetadataCallback): void|Promise<Metadata> {
664666
const reqOpts = {
665667
name: this.formattedName_,
666668
};
@@ -904,9 +906,9 @@ class Database extends ServiceObject {
904906
callback(err, null);
905907
return;
906908
}
907-
session.beginTransaction(options, (err, transaction) => {
909+
session!.beginTransaction(options, (err, transaction) => {
908910
if (err) {
909-
this.pool_.release(session);
911+
this.pool_.release(session!);
910912
callback(err, null);
911913
return;
912914
}
@@ -930,10 +932,10 @@ class Database extends ServiceObject {
930932
callback(err, null);
931933
return;
932934
}
933-
config.reqOpts.session = session.formattedName_;
935+
config.reqOpts.session = session!.formattedName_;
934936
// tslint:disable-next-line only-arrow-functions
935937
this.request(config, function() {
936-
pool.release(session);
938+
pool.release(session!);
937939
callback.apply(null, arguments);
938940
});
939941
});

src/session-pool.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
492492
* @param {Session} session The session object.
493493
*/
494494
_borrow(session: Session): void {
495-
const type = session.type;
495+
const type = session.type!;
496496
const index = this._inventory[type].indexOf(session);
497497

498498
this._inventory.borrowed.add(session);
@@ -634,7 +634,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
634634
continue;
635635
}
636636

637-
const type = session.type;
637+
const type = session.type!;
638638
const index = this._inventory[type].indexOf(session);
639639

640640
this._inventory[type].splice(index, 1);
@@ -680,7 +680,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
680680
];
681681

682682
return sessions.filter(session => {
683-
return Date.now() - session.lastUsed >= idlesAfter;
683+
return Date.now() - session.lastUsed! >= idlesAfter;
684684
});
685685
}
686686

@@ -762,7 +762,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
762762
// unpinged sessions only stay good for 1 hour
763763
const MAX_DURATION = 60000 * 60;
764764

765-
return Date.now() - session.lastUsed < MAX_DURATION;
765+
return Date.now() - session.lastUsed! < MAX_DURATION;
766766
}
767767

768768
/**
@@ -829,7 +829,7 @@ export class SessionPool extends EventEmitter implements SessionPoolInterface {
829829
* @param {Session} session The session object.
830830
*/
831831
_release(session: Session): void {
832-
const type = session.type;
832+
const type = session.type!;
833833

834834
this._inventory[type].unshift(session);
835835
this._inventory.borrowed.delete(session);

src/session.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import * as is from 'is';
2727
import * as r from 'request';
2828
import {Transaction, TransactionOptions} from './transaction';
2929
import {Database} from './database';
30-
import {ServiceObjectConfig, DeleteCallback, Metadata, GetMetadataCallback, ResponseCallback} from '@google-cloud/common';
30+
import {ServiceObjectConfig, DeleteCallback, Metadata, MetadataCallback} from '@google-cloud/common';
3131
import {CreateSessionOptions} from './common';
3232

3333
export type GetSessionResponse = [Session, r.Response];
@@ -83,6 +83,10 @@ export type BeginTransactionResponse = [Transaction, r.Response];
8383
*/
8484
export class Session extends ServiceObject {
8585
id!: string;
86+
formattedName_?: string;
87+
type?: string;
88+
txn?: Transaction;
89+
lastUsed?: number;
8690
constructor(database: Database, name?: string) {
8791
const methods = {
8892
/**
@@ -339,8 +343,8 @@ export class Session extends ServiceObject {
339343
* });
340344
*/
341345
getMetadata(): Promise<[Metadata]>;
342-
getMetadata(callback: GetMetadataCallback): void;
343-
getMetadata(callback?: GetMetadataCallback): void|Promise<[Metadata]> {
346+
getMetadata(callback: MetadataCallback): void;
347+
getMetadata(callback?: MetadataCallback): void|Promise<[Metadata]> {
344348
const reqOpts = {
345349
name: this.formattedName_,
346350
};

test/database.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ describe('Database', () => {
240240
},
241241
});
242242

243-
const database = new Database(instanceInstance, NAME);
243+
// tslint:disable-next-line no-any
244+
const database: any = new Database(instanceInstance, NAME);
244245
assert(database instanceof FakeGrpcServiceObject);
245246

246247
const calledWith = database.calledWith_[0];

test/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ describe('Spanner', () => {
690690
});
691691

692692
it('should return an Operation object', () => {
693-
const operation = spanner.operation(NAME);
693+
// tslint:disable-next-line no-any
694+
const operation: any = spanner.operation(NAME);
694695
assert(operation instanceof FakeGrpcOperation);
695696
assert.strictEqual(operation.calledWith_[0], spanner);
696697
assert.strictEqual(operation.calledWith_[1], NAME);

test/session-pool.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import * as sinon from 'sinon';
2323
import * as stackTrace from 'stack-trace';
2424
import * as timeSpan from 'time-span';
2525

26-
import {Session} from '../src';
26+
import {Session, Transaction} from '../src';
2727
import {Database} from '../src/database';
2828
import * as sp from '../src/session-pool';
2929

@@ -407,7 +407,7 @@ describe('SessionPool', () => {
407407
describe('getWriteSession', () => {
408408
it('should pass back the session and txn', done => {
409409
const fakeSession = createSession();
410-
const fakeTxn = new FakeTransaction();
410+
const fakeTxn = new FakeTransaction() as Transaction;
411411

412412
fakeSession.txn = fakeTxn;
413413

@@ -496,7 +496,7 @@ describe('SessionPool', () => {
496496

497497
sessionPool._release = noop;
498498
inventory.borrowed.add(session);
499-
session.txn = {};
499+
session.txn = {} as Transaction;
500500

501501
sessionPool.release(session);
502502
assert.strictEqual(session.txn, undefined);
@@ -507,7 +507,7 @@ describe('SessionPool', () => {
507507

508508
sessionPool._release = noop;
509509
inventory.borrowed.add(session);
510-
session.lastUsed = null;
510+
session.lastUsed = null!;
511511

512512
sessionPool.release(session);
513513
assert(isAround(session.lastUsed, Date.now()));

0 commit comments

Comments
 (0)