Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
fix: make operationsClient and service stub public
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and alexander-fenster committed Dec 11, 2019
1 parent 3bd9034 commit 0c22cd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/v1/speech_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ const version = require('../../../package.json').version;
*/
export class SpeechClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _speechStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _terminated = false;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
speechStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of SpeechClient.
Expand Down Expand Up @@ -150,7 +151,7 @@ export class SpeechClient {
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);

const operationsClient = gaxModule
this.operationsClient = gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined,
Expand All @@ -165,7 +166,7 @@ export class SpeechClient {

this._descriptors.longrunning = {
longRunningRecognize: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse),
longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)
),
Expand All @@ -186,7 +187,7 @@ export class SpeechClient {

// Put together the "service stub" for
// google.cloud.speech.v1.Speech.
this._speechStub = gaxGrpc.createStub(
this.speechStub = gaxGrpc.createStub(
opts.fallback
? (protos as protobuf.Root).lookupService(
'google.cloud.speech.v1.Speech'
Expand All @@ -205,7 +206,7 @@ export class SpeechClient {
];

for (const methodName of speechStubMethods) {
const innerCallPromise = this._speechStub.then(
const innerCallPromise = this.speechStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -465,7 +466,7 @@ export class SpeechClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._speechStub.then(stub => {
return this.speechStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
13 changes: 7 additions & 6 deletions src/v1p1beta1/speech_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ const version = require('../../../package.json').version;
*/
export class SpeechClient {
private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}};
private _speechStub: Promise<{[name: string]: Function}>;
private _innerApiCalls: {[name: string]: Function};
private _terminated = false;
auth: gax.GoogleAuth;
operationsClient: gax.OperationsClient;
speechStub: Promise<{[name: string]: Function}>;

/**
* Construct an instance of SpeechClient.
Expand Down Expand Up @@ -150,7 +151,7 @@ export class SpeechClient {
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);

const operationsClient = gaxModule
this.operationsClient = gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined,
Expand All @@ -165,7 +166,7 @@ export class SpeechClient {

this._descriptors.longrunning = {
longRunningRecognize: new gaxModule.LongrunningDescriptor(
operationsClient,
this.operationsClient,
longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse),
longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)
),
Expand All @@ -186,7 +187,7 @@ export class SpeechClient {

// Put together the "service stub" for
// google.cloud.speech.v1p1beta1.Speech.
this._speechStub = gaxGrpc.createStub(
this.speechStub = gaxGrpc.createStub(
opts.fallback
? (protos as protobuf.Root).lookupService(
'google.cloud.speech.v1p1beta1.Speech'
Expand All @@ -205,7 +206,7 @@ export class SpeechClient {
];

for (const methodName of speechStubMethods) {
const innerCallPromise = this._speechStub.then(
const innerCallPromise = this.speechStub.then(
stub => (...args: Array<{}>) => {
return stub[methodName].apply(stub, args);
},
Expand Down Expand Up @@ -466,7 +467,7 @@ export class SpeechClient {
*/
close(): Promise<void> {
if (!this._terminated) {
return this._speechStub.then(stub => {
return this.speechStub.then(stub => {
this._terminated = true;
stub.close();
});
Expand Down
6 changes: 3 additions & 3 deletions synth.metadata
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"updateTime": "2019-11-22T19:40:37.666421Z",
"updateTime": "2019-12-11T12:25:39.760739Z",
"sources": [
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "3ba7ddc4b2acf532bdfb0004ca26311053c11c30",
"internalRef": "281852671"
"sha": "e47fdd266542386e5e7346697f90476e96dc7ee8",
"internalRef": "284822593"
}
},
{
Expand Down

0 comments on commit 0c22cd7

Please sign in to comment.