-
Notifications
You must be signed in to change notification settings - Fork 13
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.
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
? |
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. |
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 |
How about yielding a custom class instead of the result of getattr()? |
That seems possible and is essentially what gcloud team do with |
Can you update the PR to try this ? |
If I disable |
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 |
LGTM Can you update the PR to reflect this. On 28 April 2016 at 09:12, geigerj [email protected] wrote:
This email may be confidential or privileged. If you received this |
@geigerj How would I make the initial non-streaming request (when I do not yet have a token)? |
One option would be to set |
as a refinement, make an appropriately named public constant in the GAX library with the value 0, e,g INITIAL_PAGE and use that. |
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 |
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,
|
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.
Updated. Good point; if we don't need to, it's better not to tie the page token to a particular type. |
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
|
looks good to me |
LGTM, but bump the version please. I think this probably corresponds to a new minor version. Can you also
|
The version was updated in the first commit already. Will push the tags following the merge. |
Fixes #86 |
Thanks for implementing this feature. When do you expect to make a PyPI release which includes it? |
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.) |
I know this is merged already, and am looking at how |
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