Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait for client before checking for terminate #186

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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