Repository navigation
Conversation
Workflow code can read a Stream through Core. Core reads the Store and gives each page of Records to Workflow code. The protos, the call code and Core's side are one commit, since none compiles alone.
The tests drive a Worker on a mock history and a test Store. They cover the pages, the caps, the idle time, the replay of Records, the shutdown and the metrics.
This branch has not been deployed
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 was changed
This PR lets Core read a Stream itself, for Workflow code. Workflow code gets each page of Records in an activation, as it arrives.
It's a prototype, created for the purpose of getting your feedback on the design. Its base is #1801, which has the append and the close. The Python SDK's side is temporalio/sdk-python#2132.
StartStreamReadandCloseStreamReadare commands for Core, not for the server.ResolveStreamReadgives each page and the end of a read.read_page_records, 256 by default.read_min_gapis an opt-in least time between two batches, for fewer activations on a slow Stream. A read holds at mostread_ahead_bytesof Records that wait, 4 MiB by default.records_in_historythe marker has the Records, about 1 MiB of them.WorkflowErrorType::StreamReplay.Why?
A library that iterates a Stream in Workflow code needs each Record while its Producer still runs. ADK is an example, since its own loop reads the model through an async generator. A Local Activity for each batch gives one marker for each batch. With this PR, an iteration costs one marker for each Workflow Task that it spans.
These points are open.
read_min_gap, a read wakes Workflow code for each Record on a Stream that isn't busy, which costs CPU. Is an opt-in gap the right setting for it?Checklist
crates/sdk-core/src/core_tests/streams/reads.rsdrive Core with a mock history and the test Store of feat: let Core append to and close a Stream for Workflow code #1801. The integration tests that need a Temporal server have no Stream case yet.records_digestdocuments the encoding of the digest, and a unit test pins it.