Repository navigation
Conversation
`@nexus.poll items=` makes the iterator yield the items of each page, and `resume=` names the helper that resumes after one item. The iterator's `next_request` lets a caller save its place.
This was referenced Oct 28, 2026
Owner
Author
|
Duplicate of #92, which has the same commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
This PR lets a Python poll iterator yield the items of each page, with a point to resume from.
items="<field>"names a list field of the response. The iterator yields its items, not the pages. The page helper stays(request, response) -> next request | None.resume=names an optional helper(page request, item) -> requestthat resumes after that item. The stream sample's helper setsfrom_offsetto the item's offset plus 1.PollIterator, in a new_poll.pymodule of the package, withnext_request. After an item, it is the resume helper's request. After a page's last item, or after a page with no item, it is the page helper's request. It isNoneafter the last page. A caller saves it and resumes with it.nexgen refuses
itemsthat names no field of the response or a field that isn't a list,resumewith noitems, and aresumehelper that isn't a support helper path.The stream sample's read takes
items="records"and the resume helper, sostream.iter_read()yields each Record. The poll-service sample's feed takesitems="executions", so the iterators of a service with no endpoint and of its resource method yield items, in Workflow code and in a client. Its response now declaresexecutions, with the Workflow execution info of the proto-backed showcase.TypeScript and .NET get item polls with their client targets. Go and Java ignore
@nexus.poll, as before.It is for review here before it goes upstream. It sits on the upstream stack temporalio#308, temporalio#310, temporalio#311, temporalio#297, temporalio#296, temporalio#303, temporalio#304, temporalio#309, temporalio#318, temporalio#319, temporalio#320, temporalio#321, temporalio#322, temporalio#323, temporalio#324, temporalio#325, whose head is
review/p3-base, and on #77, #79, #81, #83, #86, #88, #90.Why?
The Stream API of the proposal reads Records one by one, and a reader saves its place to resume after a restart. The page iterator of temporalio#325 yields responses, so each caller looped over the Records and tracked the offset itself.
The design put one
PollIteratorclass in each module that has an item poll. This PR puts it in one module of the package, which each module imports.How did you test it?
A Python test reads two pages with an empty one between them, and checks
next_requestafter each item and after the last page. Another checks that an empty page keeps its offset. The poll-service tests read the feed's items from a client, from a resource method, and from Workflow code against the test server. Rejection fixtures cover each refusal.cargo validatepasses.