Skip to content

[Brook K14] Added readers with resume points and withdrawn offsets. - #224

Closed
moetemp wants to merge 1 commit into
moe/brook/review/streams-k13-workflow-writesfrom
moe/brook/review/streams-k14-readers
Closed

moetemp wants to merge 1 commit into
moe/brook/review/streams-k13-workflow-writesfrom
moe/brook/review/streams-k14-readers

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds readers. A reader keeps the state of one subscribe, so lang only decodes each item.

  • OpenReader checks the options and keeps them. ReadNext reads pages until one has items, the read ends or max_wait passes, and returns that page. Each item carries the resume point after it, as Subscription.next_offset moves per item.
  • A Superseded item lists the offsets of the Records that this read gave and the item withdraws. Client Records aren't kept, since nothing withdraws them.
  • The reader keeps the create wait, which starts at the first ReadNext, the end of a read with no wait, the newest-last first page, and the pause after a quick empty page. last takes no offset and no END.
  • A dropped ReadNext leaves the reader as it was, so a cancel loses no item. A wait of more than a year counts as a year.
  • The static Withdraws applies the withdrawal rule to a Producer of an earlier read. epoch::withdraws_producer is that rule for a Producer, and withdraws calls it.
  • The rule is K7's. sdk-python's withdraws also has a fallback for a completed task with attempt 0, which compares started times. It isn't here, since Core sends the attempt with C1's field 6. It matters only when Core doesn't know the attempt.

Depends on #223 (K13). Review lane is the Rust reviewers.
Part of the Brook review series.

Why?

sdk-python's _reader.py and _items.py hold the page loop, the waits and the withdrawal rule today. They are the same in every language.

How did you test it?

cargo fmt, cargo clippy -- -D warnings (with and without features), cargo test -p temporalio-streams --all-features and cargo doc pass at this commit. The reader suite runs on the memory Store here, and on Redis in R4 (temporal-community/sdk-streams#4).

@moetemp moetemp added the skip-changelog Changelog entry rides another PR label Oct 28, 2026
@moetemp
moetemp force-pushed the moe/brook/review/streams-k13-workflow-writes branch from 1bd0d50 to e6a73aa Compare October 28, 2026 18:45
@moetemp
moetemp force-pushed the moe/brook/review/streams-k14-readers branch from 45029f7 to 91b73d5 Compare October 28, 2026 18:45
@moetemp
moetemp marked this pull request as draft October 28, 2026 21:55
@moetemp
moetemp force-pushed the moe/brook/review/streams-k14-readers branch 2 times, most recently from b4a1e0d to 1965e18 Compare October 29, 2026 04:06
@moetemp
moetemp force-pushed the moe/brook/review/streams-k13-workflow-writes branch 2 times, most recently from 112c437 to 750716b Compare October 29, 2026 08:37
@moetemp
moetemp force-pushed the moe/brook/review/streams-k14-readers branch from 1965e18 to 4bade9b Compare October 29, 2026 08:37
@moetemp
moetemp force-pushed the moe/brook/review/streams-k13-workflow-writes branch from 750716b to f891bac Compare October 29, 2026 09:17
@moetemp
moetemp force-pushed the moe/brook/review/streams-k14-readers branch from 4bade9b to b457a88 Compare October 29, 2026 09:17
A reader keeps the page loop, the waits and the offsets that each Superseded item withdraws, so each SDK only decodes the items. `Withdraws` applies the same rule to Records of an earlier read.
@moetemp
moetemp force-pushed the moe/brook/review/streams-k13-workflow-writes branch from f891bac to 88ce46f Compare October 29, 2026 10:03
@moetemp
moetemp force-pushed the moe/brook/review/streams-k14-readers branch from b457a88 to 534ffb5 Compare October 29, 2026 10:03
@moetemp

moetemp commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Parked. Nothing calls these runtime methods yet, since sdk-python does this work in Python. The branch stays, and this layer comes back with its first caller, for example a TypeScript or .NET port or Rust read handles.

@moetemp moetemp closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Changelog entry rides another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant