Skip to content

[Brook S3] Added Stream definitions, handles, Records and errors to temporalio.common. - #373

Open
moetemp wants to merge 1 commit into
moe/brook/review/feature-streamsfrom
moe/brook/review/s3-data-model
Open

moetemp wants to merge 1 commit into
moe/brook/review/feature-streamsfrom
moe/brook/review/s3-data-model

Conversation

@moetemp

@moetemp moetemp commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

What was changed

This PR adds Stream definitions, handles, Records and the Stream errors to temporalio.common, as the data model of the Streams API.

  • A definition subclasses StreamDefinition[T] and has @common.defn. It gives a Stream its name and its one payload type, and each handle class is generic in that type, such as ActivityStream[Turn]. There are no Topics, so separate channels are separate Streams.
  • StreamHandle converts to the StreamRef proto JSON through G2's nested conversion, so a Workflow can pass it to an Activity, a child or the next run. A Workflow's Stream has owner, an Execution with type EXECUTION_TYPE_WORKFLOW, the Workflow ID as businessId and the first run id as runId. A client's Stream has no owner. The handle keeps its workflow_id and first_execution_run_id properties.
  • Record.producer.kind and Superseded.supersession.producer_kind are the generated StreamProducerKind enum, A1's name. The prototype's class was ProducerKind, with the same int values.
  • Each error class maps a case of A1's StreamErrorReason, and StreamError.reason is that enum. A reason with no class of its own, such as SEQUENCE, gives StreamError. StreamOptions has what a create sets, Retention for now.
  • The ids and withdrawal rules match the crate's, and the tests check them against the crate's shared vectors.
  • temporalio.common imports the Stream names on first use, since the Stream modules import temporalio.client and temporalio.workflow. So import temporalio.common loads no Stream module.

Depends on S2 (#372) and G2 (#368). The base is moe/brook/review/feature-streams (G1, G2, G3, S1, S2 and B1), the fork's copy of upstream feature/streams. No changelog fragment, since S9 has the Streams entry.
Part of the Brook review series.

Why?

Every later Streams PR builds on these types. They need no backend and no server.

Open question. temporalio.common gets its first __all__, which changes from temporalio.common import *. Is that OK?

Checklist

  1. How was this tested:
    • poe lint, poe gen-docs and pytest tests/contrib/streams on a build with the streams feature.
    • Fork CI passes, except the arm jobs, since the fork has no arm runners.

@moetemp moetemp added the skip-changelog Changelog entry rides another PR label Oct 25, 2026
@moetemp
moetemp force-pushed the moe/brook/review/feature-streams branch from 9e54468 to 4c0260b Compare October 26, 2026 00:14
@moetemp
moetemp force-pushed the moe/brook/review/s3-data-model branch 2 times, most recently from 347fb8d to 9e969ce Compare October 26, 2026 02:08
@moetemp
moetemp force-pushed the moe/brook/review/feature-streams branch 2 times, most recently from c4ce9d7 to c22d918 Compare October 26, 2026 08:44
@moetemp
moetemp force-pushed the moe/brook/review/s3-data-model branch 2 times, most recently from 9b54b39 to fda6c46 Compare October 27, 2026 09:07
@moetemp
moetemp force-pushed the moe/brook/review/feature-streams branch from 479a894 to 63423ea Compare October 27, 2026 09:17
@moetemp
moetemp force-pushed the moe/brook/review/s3-data-model branch from fda6c46 to 5a0f9bf Compare October 27, 2026 09:17
They are the data model of the Streams API in `temporalio.common`. A
handle is data, so a Workflow can pass it to an Activity, a child or the
next run.
@moetemp
moetemp force-pushed the moe/brook/review/s3-data-model branch from 5a0f9bf to 7a7e940 Compare October 28, 2026 01:33
@moetemp
moetemp force-pushed the moe/brook/review/feature-streams branch from 63423ea to 6a7f134 Compare October 28, 2026 01:33
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