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!: remove pageSize/pageToken from call settings #1263

Merged
merged 3 commits into from
May 9, 2022
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
16 changes: 0 additions & 16 deletions src/gax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ export interface CallOptions {
timeout?: number;
retry?: Partial<RetryOptions> | null;
autoPaginate?: boolean;
pageToken?: string;
pageSize?: number;
maxResults?: number;
maxRetries?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -177,7 +175,6 @@ export class CallSettings {
this.retry = settings.retry as RetryOptions;
this.autoPaginate =
'autoPaginate' in settings ? settings.autoPaginate : true;
this.pageToken = settings.pageToken;
this.maxResults = settings.maxResults;
this.otherArgs = settings.otherArgs || {};
this.bundleOptions = settings.bundleOptions;
Expand All @@ -203,8 +200,6 @@ export class CallSettings {
let timeout = this.timeout;
let retry = this.retry;
let autoPaginate = this.autoPaginate;
let pageToken = this.pageToken;
let pageSize = this.pageSize;
let maxResults = this.maxResults;
let otherArgs = this.otherArgs;
let isBundling = this.isBundling;
Expand Down Expand Up @@ -246,15 +241,6 @@ export class CallSettings {
autoPaginate = false;
}

if ('pageToken' in options) {
autoPaginate = false;
pageToken = options.pageToken;
}

if ('pageSize' in options) {
pageSize = options.pageSize;
}

if ('maxResults' in options) {
maxResults = options.maxResults;
}
Expand Down Expand Up @@ -294,8 +280,6 @@ export class CallSettings {
bundleOptions: this.bundleOptions,
longrunning,
autoPaginate,
pageToken,
pageSize,
maxResults,
otherArgs,
isBundling,
Expand Down
11 changes: 1 addition & 10 deletions src/paginationCalls/pagedApiCaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ export class PagedApiCaller implements APICaller {
* It's supposed to be a gRPC service stub function wrapped into several layers of wrappers that make it
* accept just two parameters: (request, callback).
* @param request A request object that came from the user.
* @param settings Call settings. We are interested in `maxResults`, autoPaginate`, `pageToken`, and `pageSize`
* (they are all optional).
* @param settings Call settings. We are interested in `maxResults` and `autoPaginate` (they are optional).
* @param ongoingCall An instance of OngoingCall or OngoingCallPromise that can be used for call cancellation,
* and is used to return results to the user.
*/
Expand All @@ -148,14 +147,6 @@ export class PagedApiCaller implements APICaller {
) {
request = Object.assign({}, request);

// If settings object contain pageToken or pageSize, override the corresponding fields in the request object.
if (settings.pageToken) {
request[this.pageDescriptor.requestPageTokenField] = settings.pageToken;
}
if (settings.pageSize) {
request[this.pageDescriptor.requestPageSizeField!] = settings.pageSize;
}

if (!settings.autoPaginate) {
// they don't want auto-pagination this time - okay, just call once
ongoingCall.call(apiCall, request);
Expand Down
11 changes: 5 additions & 6 deletions test/unit/pagedIteration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,17 @@ describe('paged iteration', () => {
});

it('ignores autoPaginate options, but respects others', done => {
// Specifies autoPaginate: false, which will be ignored, and pageToken:
// pageSize which will be used so that the stream will start from the
// specified token.
const options = {pageToken: pageSize, autoPaginate: false};
// Specifies autoPaginate: false, which will be ignored, and maxResults:
// pageSize which will be used.
const options = {maxResults: pageSize, autoPaginate: false};
streamChecker(
// @ts-ignore incomplete options
descriptor.createStream(apiCall, {}, options),
() => {
assert.strictEqual(spy.callCount, pagesToStream);
assert.strictEqual(spy.callCount, 1);
},
done,
pageSize
0
);
});

Expand Down