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

feat: support async iterator for paging method #199

Merged
merged 18 commits into from
Mar 30, 2020
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
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
Loading