Repository navigation
Conversation
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
…-activity-handles
Owner
Author
|
Closing as stale. This layer is folded into the v5 tip, #365, and the upstream review uses a fresh series instead. Plan: https://www.notion.so/4048fc567738814990b7c796ac28fe3f |
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 adds the Activity handles
ActivityStreamandSyncActivityStream, their Topics, andBufferedPublisher.An Activity gets a Stream only as an argument, such as a field of its one input object.
await topic.publish(*values)writes the Records with oneWriteRecordscall and returns the offset of the last one. The sync handle blocks the Activity thread and runs the call on the Worker's loop. Both handles also read, give the next offset, and close. A handle of another backend raisesStreamUnsupportedError.streams.BufferedPublisher(topic, max_delay=timedelta(milliseconds=100))is the optional helper that batches.publishreturns at once, a batch goes out at mostmax_delayafter its first value,flush()writes the rest, andasync withflushes at the end of the block.After a batch fails, the publisher writes nothing more, so a reader sees no gap, and each later call raises the error. The end of an Activity attempt flushes the attempt's open publishers, and a write error there fails the attempt unless the Activity already saw it.
A cancel of a sync Activity also cancels the call that it waits for on the Worker's loop.
Before a Local Activity runs, the plugin calls the crate's
FlushRunBufferwith the dispatching Workflow Task's facts, so the run's Records come before the Local Activity's. A failure fails the attempt. A retried attempt opens a writer on each Stream it received, which withdraws the earlier attempt's Records also when the new attempt writes nothing. It finds the Streams in arguments, fields, slots, lists and dicts.Why?
S47, S67, S70, S71 and S79: an awaited publish has published when it returns, with no hidden timer, and a Local Activity sees the Records that its run wrote before it.
How did you test it?
Live tests in
tests/contrib/streams/test_activity_handles.pyon the memory Store and on a scratchredis-server: offsets from async and sync publishes, a read in an Activity, a buffered publisher, a retry that withdraws a received Stream's Records, a close from an Activity, the backend check, and the order of Workflow and Local Activity Records. A publisher that is never flushed, Streams in a list and an optional field of a retried Activity's input, and a sync read. Unit tests cover the buffered publisher's batching and sticky errors, and the cancel of a blocked sync call.pyright,mypy,basedpyright,pydocstyle,ruff.