Skip to content

Commit

Permalink
feat: support async iterator for paging method (#199)
Browse files Browse the repository at this point in the history
* init interface to async iterator

* tts should pass

* feedback

* change the dependency to gax github branch

* update baseline

* make it work

* gts fix

* add timeout for test application

* add timeout

* feat: generate test to libraries with pagination method using async iterator (#208)

* add test for paging method using async iterator

* fix

* fix

* fix: google gax version

* fix: make grpc-fallback work

* fix(deps): use google-gax ^2.0.1

Co-authored-by: Alexander Fenster <fenster@google.com>
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
3 people committed Mar 30, 2020
1 parent e10b5b8 commit 4d41ad3
Show file tree
Hide file tree
Showing 62 changed files with 6,656 additions and 1,673 deletions.
2 changes: 1 addition & 1 deletion baselines/bigquery-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.0.0"
"google-gax": "^2.0.1"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {APICallback, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import * as protos from '../../protos/protos';
Expand Down Expand Up @@ -194,9 +194,8 @@ export class BigQueryStorageClient {
// and create an API call method for each.
const bigQueryStorageStubMethods =
['createReadSession', 'readRows', 'batchCreateReadSessionStreams', 'finalizeStream', 'splitReadStream'];

for (const methodName of bigQueryStorageStubMethods) {
const innerCallPromise = this.bigQueryStorageStub.then(
const callPromise = this.bigQueryStorageStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
Expand All @@ -209,20 +208,14 @@ export class BigQueryStorageClient {
});

const apiCall = this._gaxModule.createApiCall(
innerCallPromise,
callPromise,
this._defaults[methodName],
this.descriptors.page[methodName] ||
this.descriptors.stream[methodName] ||
this.descriptors.longrunning[methodName]
);

this.innerApiCalls[methodName] = (
argument: {},
callOptions?: CallOptions,
callback?: APICallback
) => {
return apiCall(argument, callOptions, callback);
};
this.innerApiCalls[methodName] = apiCall;
}

return this.bigQueryStorageStub;
Expand Down Expand Up @@ -293,14 +286,14 @@ export class BigQueryStorageClient {
options: gax.CallOptions,
callback: Callback<
protos.google.cloud.bigquery.storage.v1beta1.IReadSession,
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined,
{}|null|undefined>): void;
createReadSession(
request: protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest,
callback: Callback<
protos.google.cloud.bigquery.storage.v1beta1.IReadSession,
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined,
{}|null|undefined>): void;
/**
* Creates a new read session. A read session divides the contents of a
* BigQuery table into one or more streams, which can then be used to read
Expand Down Expand Up @@ -350,11 +343,12 @@ export class BigQueryStorageClient {
request: protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest,
optionsOrCallback?: gax.CallOptions|Callback<
protos.google.cloud.bigquery.storage.v1beta1.IReadSession,
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, {}|undefined>,
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined,
{}|null|undefined>,
callback?: Callback<
protos.google.cloud.bigquery.storage.v1beta1.IReadSession,
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined,
{}|undefined>):
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined,
{}|null|undefined>):
Promise<[
protos.google.cloud.bigquery.storage.v1beta1.IReadSession,
protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, {}|undefined
Expand Down Expand Up @@ -392,14 +386,14 @@ export class BigQueryStorageClient {
options: gax.CallOptions,
callback: Callback<
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse,
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined,
{}|null|undefined>): void;
batchCreateReadSessionStreams(
request: protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest,
callback: Callback<
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse,
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined,
{}|null|undefined>): void;
/**
* Creates additional streams for a ReadSession. This API can be used to
* dynamically adjust the parallelism of a batch processing task upwards by
Expand All @@ -424,11 +418,12 @@ export class BigQueryStorageClient {
request: protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest,
optionsOrCallback?: gax.CallOptions|Callback<
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse,
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, {}|undefined>,
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined,
{}|null|undefined>,
callback?: Callback<
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse,
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined,
{}|undefined>):
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined,
{}|null|undefined>):
Promise<[
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse,
protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, {}|undefined
Expand Down Expand Up @@ -465,14 +460,14 @@ export class BigQueryStorageClient {
options: gax.CallOptions,
callback: Callback<
protos.google.protobuf.IEmpty,
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined,
{}|null|undefined>): void;
finalizeStream(
request: protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest,
callback: Callback<
protos.google.protobuf.IEmpty,
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined,
{}|null|undefined>): void;
/**
* Triggers the graceful termination of a single stream in a ReadSession. This
* API can be used to dynamically adjust the parallelism of a batch processing
Expand Down Expand Up @@ -503,11 +498,12 @@ export class BigQueryStorageClient {
request: protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest,
optionsOrCallback?: gax.CallOptions|Callback<
protos.google.protobuf.IEmpty,
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, {}|undefined>,
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined,
{}|null|undefined>,
callback?: Callback<
protos.google.protobuf.IEmpty,
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined,
{}|undefined>):
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined,
{}|null|undefined>):
Promise<[
protos.google.protobuf.IEmpty,
protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, {}|undefined
Expand Down Expand Up @@ -544,14 +540,14 @@ export class BigQueryStorageClient {
options: gax.CallOptions,
callback: Callback<
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse,
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined,
{}|null|undefined>): void;
splitReadStream(
request: protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest,
callback: Callback<
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse,
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined,
{}|undefined>): void;
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined,
{}|null|undefined>): void;
/**
* Splits a given read stream into two Streams. These streams are referred to
* as the primary and the residual of the split. The original stream can still
Expand Down Expand Up @@ -589,11 +585,12 @@ export class BigQueryStorageClient {
request: protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest,
optionsOrCallback?: gax.CallOptions|Callback<
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse,
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, {}|undefined>,
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined,
{}|null|undefined>,
callback?: Callback<
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse,
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined,
{}|undefined>):
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined,
{}|null|undefined>):
Promise<[
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse,
protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, {}|undefined
Expand Down
2 changes: 1 addition & 1 deletion baselines/disable-packing-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.0.0"
"google-gax": "^2.0.1"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
Expand Down

0 comments on commit 4d41ad3

Please sign in to comment.