Uh oh!
There was an error while loading. Please reload this page.
Change page-streaming behavior - #94
Conversation
Now return an iterable over pages of the response resource field, rather than the return type, for page stream-able calls where page streaming is disabled. Note that this removes the ability to get a standard gRPC/proto response from any call that is capable of page streaming.
geigerj
commented
Apr 26, 2016
geigerj
commented
Apr 26, 2016
My primary concern with this approach is that it is no longer possible to access any fields in the response type beside the repeated resources field. What if an API wants to send a response type that looks like, e.g. or ? |
tbetbetbe
commented
Apr 26, 2016
GAX provides support for specific API patterns. There is a doc (currently internal) that describes the API patterns that GAX aims to support. IUC, the cases you've described contravene the rules it lays out for page-streaming calls. |
Case 2 actually comes from the document you referenced (foo_count actually should be the total count of foos, across all pages). There are examples of the first case internally as well, although they may be nonstandard, as you suggested. |
geigerj
commented
Apr 26, 2016
It also might be worth taking a look at googleapis/google-cloud-python#895, which discusses a similar feature. |
See also the "list" examples in googleapis/google-cloud-python#1722 |
jmuk
commented
Apr 26, 2016
How about yielding a custom class instead of the result of getattr()? |
geigerj
commented
Apr 26, 2016
That seems possible and is essentially what gcloud team do with |
tbetbetbe
commented
Apr 27, 2016
Can you update the PR to try this ? |
tseaver
commented
Apr 27, 2016
If I disable |
geigerj
commented
Apr 28, 2016
You're right -- you can't currently pass a page token through the wrapper list_resource methods in the generated code. I would suggest we replace the |
tbetbetbe
commented
Apr 28, 2016
LGTM Can you update the PR to reflect this. On 28 April 2016 at 09:12, geigerj notifications@github.com wrote:
This email may be confidential or privileged. If you received this |
tseaver
commented
Apr 28, 2016
@geigerj How would I make the initial non-streaming request (when I do not yet have a token)? |
geigerj
commented
Apr 28, 2016
One option would be to set |
tbetbetbe
commented
Apr 29, 2016
as a refinement, make an appropriately named public constant in the GAX library with the value 0, e,g INITIAL_PAGE and use that. |
tseaver
commented
Apr 29, 2016
Hmmm, I was under the impression that page tokens are opaque strings, rather than integers (my guess is that they capture some kind of "generational" state for the request). Is |
geigerj
commented
Apr 29, 2016
In that case, an empty string, rather than 0. For the first page, you'd want to pass in the proto3 default value for that field. |
Now, if page streaming is set to per-page (rather than per-resource), it is possible to specify a page token to the request. It is also possible to retrieve the full response message, as well as the next page token, from the per-page iterator.
Updated. In the new version,
|
jmuk
commented
Apr 29, 2016
Sorry I haven't caught up the discussion here, but I don't think there is rules for the type of the page tokens. I believe they are almost always string, but theoretically some API can publish methods with numeric page tokens or messages. Why not adopting the same approach as OPTION_INHERIT? i.e.
|
Previously, assumed page_token was a string. Now it can have any type.
geigerj
commented
Apr 29, 2016
Updated. Good point; if we don't need to, it's better not to tie the page token to a particular type. |
codecov-io
commented
Apr 29, 2016
Current coverage is 97.02%@@ master #94 diff @@
==========================================
Files 8 8 Lines 539 571 +32 Methods 0 0 Messages 0 0 Branches 0 0 ==========================================
+ Hits 522 554 +32
Misses 17 17 Partials 0 0
|
jmuk
commented
Apr 29, 2016
looks good to me |
tbetbetbe
commented
Apr 29, 2016
LGTM, but bump the version please. I think this probably corresponds to a new minor version. Can you also
|
geigerj
commented
Apr 29, 2016
The version was updated in the first commit already. Will push the tags following the merge. |
geigerj
commented
Apr 29, 2016
Fixes #86 |
tseaver
commented
May 3, 2016
Thanks for implementing this feature. When do you expect to make a PyPI release which includes it? |
geigerj
commented
May 4, 2016
I can push this to PyPI now. Tim, is there any reason I should hold off on the push, for example, to coordinate with a codegen refresh? (I may not have time to refresh codegen until a bit later, but I believe the vkit packages are pegged to the old version of GAX, so I don't think pushing this to PyPI should affect them.) |
tseaver
commented
May 16, 2016
I know this is merged already, and am looking at how |
geigerj
commented
May 16, 2016
Ah, yes, you're right. I've just filed an issue to fix this in the code generator: googleapis/gapic-generator#110. With this new set up, we should allow |
Fixes#86
Now return an iterable over pages of the response resource field,
rather than the return type, for page stream-able calls where page
streaming is disabled.
Note that this removes the ability to get a standard gRPC/proto
response from any call that is capable of page streaming.
This is intended to demonstrate one of the proposals from #86