Skip to content
New issue

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

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

Already on GitHub? # to your account

chore: remove paginator dependency and use gapic to return streams for paginated calls instead #762

Merged
merged 14 commits into from
Jul 27, 2020

Conversation

AVaksman
Copy link
Contributor

@AVaksman AVaksman commented Jul 13, 2020

gapic supports both paginated calls and its streamified versions.

  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 13, 2020
@codecov
Copy link

codecov bot commented Jul 13, 2020

Codecov Report

Merging #762 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #762   +/-   ##
=======================================
  Coverage   99.13%   99.14%           
=======================================
  Files          17       17           
  Lines       15774    15818   +44     
  Branches      951      959    +8     
=======================================
+ Hits        15638    15682   +44     
  Misses        133      133           
  Partials        3        3           
Impacted Files Coverage Δ
src/index.ts 100.00% <100.00%> (ø)
src/instance.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32c72c3...eeac2d5. Read the comment docs.

@stephenplusplus
Copy link
Contributor

@AVaksman I know it's still a draft, so sorry if I'm jumping in too soon. But, I was wondering if you could describe the intentions behind this when you get the chance? Thanks!

@AVaksman AVaksman changed the title chore: drop paginator and use gapic to return streams for paginated calls instead chore: drop paginator and use gapic to return streams for paginated calls instead Jul 16, 2020
@AVaksman AVaksman marked this pull request as ready for review July 16, 2020 17:28
@AVaksman AVaksman requested a review from a team as a code owner July 16, 2020 17:28
@AVaksman
Copy link
Contributor Author

gapic now supports paginated calls and its streamified versions directly.

@stephenplusplus
Copy link
Contributor

Does it also retry requests?

@AVaksman
Copy link
Contributor Author

Yes, gax supports retries for paged calls.
RetryOptions{retryCodes; backoffSettings;} can be passed via gaxOptions.retry argument.
Streamified version of paged call is essentially same paged call where results pushed one by one via an object mode stream.

src/index.ts Outdated
@@ -750,16 +750,20 @@ export class Bigtable {
});
};

const streamified = {listTablesStream: true};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a different variable name to better describe the difference between a method that is "streamified" and one that isn't? Does this list effectively hold GAPIC streaming methods? If so, maybe const gapicStreamingMethods = {...};?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/index.ts Outdated
@@ -805,6 +809,20 @@ export class Bigtable {
.pipe(stream);
});
}

function makeRequestStreamified() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this, too, to be more clear. Maybe makeGapicStreamRequest()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/instance.ts Outdated

// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
const transform = function (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work (minus annotations and formatting)?

// name change to indicate purpose of method
const transformToTable = (chunk, enc, next) => { // no "this" argument
  const table = this.table(chunk.name); // the Table constructor should support raw input
  table.metadata = chunk;
  next(null, table);
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!
Have to pass tableId only thought, Table constructor checks for the proper projectId presence.

@stephenplusplus
Copy link
Contributor

Thanks!

@AVaksman AVaksman added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 21, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 21, 2020
@AVaksman AVaksman changed the title chore: drop paginator and use gapic to return streams for paginated calls instead chore: remove paginator dependency and use gapic to return streams for paginated calls instead Jul 22, 2020
@AVaksman
Copy link
Contributor Author

@stephenplusplus I added another unit test after the approval

@stephenplusplus
Copy link
Contributor

Nice, lgtm!

@AVaksman AVaksman merged commit 8a2a74e into googleapis:master Jul 27, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants