Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

feat: emit 'response' with every page - #887

Merged
gcf-merge-on-green[bot] merged 4 commits into
googleapis:masterfrom
AVaksman:address_failedLocations_streamified
Sep 2, 2020
Merged

gcf-merge-on-green[bot] merged 4 commits into
googleapis:masterfrom
AVaksman:address_failedLocations_streamified

Conversation

@AVaksman

Copy link
Copy Markdown
Contributor

Bigtable.listAppProfiles supports pagination and may return a unique value failedLocations.
Currently streamified version of the paginated call does not expose failedLocations to user.

This PR offers to emit a decorated error explaining that resources from some locations are currently not available.
The error is emitted after all available resources have been push-ed to stream.

@AVaksman
AVaksman requested a review from a team August 11, 2020 21:15
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 11, 2020
@AVaksman AVaksman added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 12, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 12, 2020
@alexander-fenster

Copy link
Copy Markdown
Contributor

I feel really bad about this, and need to talk to the team about it.

@stephenplusplus

Copy link
Copy Markdown
Contributor

@AVaksman is the general problem here that from Bigtable, we need something in the raw API response, but gax isn't giving it to us in stream mode? Instead of special-casing this property, could we have the gax stream emit("response", apiResponse) or something similar each time a page is processed?

@AVaksman

Copy link
Copy Markdown
Contributor Author

@AVaksman is the general problem here that from Bigtable, we need something in the raw API response, but gax isn't giving it to us in stream mode?

Correct, the user has no access to fullApiResponse.failedLocatons in the stream mode.

@stephenplusplus

Copy link
Copy Markdown
Contributor

Would emitting that event on each paginated response work? From Bigtable, we could then use that event to collect the API responses and do whatever it needs.

@AVaksman

Copy link
Copy Markdown
Contributor Author

could we have the gax stream emit("response", apiResponse) or something similar each time a page is processed?

👍

And provide a such sample in the Bigtable. Will wait for @alexander-fenster take on this.

@alexander-fenster

Copy link
Copy Markdown
Contributor

Yes, I totally like the idea of emitting the original API response within each page received from the service. Then the manual layer can do whatever it needs with that data. Thank you for this idea @stephenplusplus!

@AVaksman Can you update this PR to do this ^^^, or do you want me to implement it? Should not be hard at all from what I understand.

@AVaksman

Copy link
Copy Markdown
Contributor Author

Will update this PR accordingly.
Will prepare the changes for the manual layer as well.
Thanks!

@AVaksman AVaksman changed the title feat: return decorated error with failedLocations info feat: emit 'response' with every page Aug 24, 2020
@AVaksman AVaksman added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 24, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 24, 2020
Comment thread test/unit/pagedIteration.ts Outdated

it('emits response event with apiCall', done => {
const onRespone = sinon.spy();
// @ts-ignore incomplete optio

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// @ts-ignore incomplete optio
// @ts-ignore incomplete option

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thank you!

Comment thread test/unit/pagedIteration.ts Outdated
});

it('emits response event with apiCall', done => {
const onRespone = sinon.spy();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const onRespone = sinon.spy();
const onResponse = sinon.spy();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Corrected here and below.

Comment thread test/unit/pagedIteration.ts Outdated
const onRespone = sinon.spy();
// @ts-ignore incomplete optio
const stream = descriptor.createStream(apiCall, {}, null);
stream.on('response', onRespone);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
stream.on('response', onRespone);
stream.on('response', onResponse);

Comment thread test/unit/pagedIteration.ts Outdated
stream.on('response', onRespone);
streamChecker(
stream,
() => assert.strictEqual(onRespone.callCount, pagesToStream + 1),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
() => assert.strictEqual(onRespone.callCount, pagesToStream + 1),
() => assert.strictEqual(onResponse.callCount, pagesToStream + 1),

@alexander-fenster

Copy link
Copy Markdown
Contributor

The browser test failure is unrelated to this change and can be ignored, I will take care of that separately.

@AVaksman AVaksman added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 26, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 26, 2020
@AVaksman AVaksman added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 27, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 27, 2020
@alexander-fenster alexander-fenster added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 28, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 28, 2020
@alexander-fenster alexander-fenster added the automerge Merge the pull request once unit tests and other checks pass. label Sep 2, 2020
@gcf-merge-on-green
gcf-merge-on-green Bot merged commit 9c7f983 into googleapis:master Sep 2, 2020
gcf-merge-on-green Bot pushed a commit that referenced this pull request Sep 2, 2020
🤖 I have created a release \*beep\* \*boop\* 
---
## [2.8.0](https://www.github.com/googleapis/gax-nodejs/compare/v2.7.0...v2.8.0) (2020-09-02)


### Features

* emit 'response' with every page ([#887](https://www.github.com/googleapis/gax-nodejs/issues/887)) ([9c7f983](https://www.github.com/googleapis/gax-nodejs/commit/9c7f98336edd75b6b5ce954b093d449d40def290)), closes [/github.com/googleapis/googleapis/blob/94fe3637559a257634d7b47a15bb8d976daff788/google/bigtable/admin/v2/bigtable_instance_admin.proto#L541](https://www.github.com/googleapis//github.com/googleapis/googleapis/blob/94fe3637559a257634d7b47a15bb8d976daff788/google/bigtable/admin/v2/bigtable_instance_admin.proto/issues/L541) [/github.com/googleapis/gax-nodejs/blob/eb7aa446dabf420d65831cd151b8b3076e087c71/src/paginationCalls/pageDescriptor.ts#L63](https://www.github.com/googleapis//github.com/googleapis/gax-nodejs/blob/eb7aa446dabf420d65831cd151b8b3076e087c71/src/paginationCalls/pageDescriptor.ts/issues/L63)
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

automerge Merge the pull request once unit tests and other checks pass. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants