Skip to content

Commit

Permalink
fix: wait for client before checking for terminate (#186)
Browse files Browse the repository at this point in the history
* fix: wait for client before checking for terminate

* fix: baselines

Co-authored-by: Alexander Fenster <[email protected]>
  • Loading branch information
schmidt-sebastian and alexander-fenster committed Dec 29, 2019
1 parent 5d8608f commit cb9136d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ export class {{ service.name }}Client {
for (const methodName of {{ service.name.toCamelCase() }}StubMethods) {
const innerCallPromise = this.{{ service.name.toCamelCase() }}Stub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return stub[methodName].apply(stub, args);
},
(err: Error|null|undefined) => () => {
Expand All @@ -264,10 +267,7 @@ export class {{ service.name }}Client {
callOptions?: CallOptions,
callback?: APICallback
) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return apiCall(argument, callOptions, callback);
return apiCall(argument, callOptions, callback);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ export class KeyManagementServiceClient {
for (const methodName of keyManagementServiceStubMethods) {
const innerCallPromise = this.keyManagementServiceStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return stub[methodName].apply(stub, args);
},
(err: Error|null|undefined) => () => {
Expand All @@ -196,10 +199,7 @@ export class KeyManagementServiceClient {
callOptions?: CallOptions,
callback?: APICallback
) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return apiCall(argument, callOptions, callback);
return apiCall(argument, callOptions, callback);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ export class CloudRedisClient {
for (const methodName of cloudRedisStubMethods) {
const innerCallPromise = this.cloudRedisStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return stub[methodName].apply(stub, args);
},
(err: Error|null|undefined) => () => {
Expand All @@ -271,10 +274,7 @@ export class CloudRedisClient {
callOptions?: CallOptions,
callback?: APICallback
) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return apiCall(argument, callOptions, callback);
return apiCall(argument, callOptions, callback);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ export class EchoClient {
for (const methodName of echoStubMethods) {
const innerCallPromise = this.echoStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return stub[methodName].apply(stub, args);
},
(err: Error|null|undefined) => () => {
Expand All @@ -215,10 +218,7 @@ export class EchoClient {
callOptions?: CallOptions,
callback?: APICallback
) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return apiCall(argument, callOptions, callback);
return apiCall(argument, callOptions, callback);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class TextToSpeechClient {
for (const methodName of textToSpeechStubMethods) {
const innerCallPromise = this.textToSpeechStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return stub[methodName].apply(stub, args);
},
(err: Error|null|undefined) => () => {
Expand All @@ -171,10 +174,7 @@ export class TextToSpeechClient {
callOptions?: CallOptions,
callback?: APICallback
) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return apiCall(argument, callOptions, callback);
return apiCall(argument, callOptions, callback);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ export class TranslationServiceClient {
for (const methodName of translationServiceStubMethods) {
const innerCallPromise = this.translationServiceStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return stub[methodName].apply(stub, args);
},
(err: Error|null|undefined) => () => {
Expand All @@ -233,10 +236,7 @@ export class TranslationServiceClient {
callOptions?: CallOptions,
callback?: APICallback
) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
return apiCall(argument, callOptions, callback);
return apiCall(argument, callOptions, callback);
};
}
}
Expand Down

0 comments on commit cb9136d

Please sign in to comment.