Skip to content

[Brook] Added StreamClient. - #345

Closed
moetemp wants to merge 14 commits into
moe/brook/v4/p22-activity-handlesfrom
moe/brook/v4/p23-stream-client
Closed

moetemp wants to merge 14 commits into
moe/brook/v4/p22-activity-handlesfrom
moe/brook/v4/p23-stream-client

Conversation

@moetemp

@moetemp moetemp commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds StreamClient, ClientStream and ClientTopic.

StreamClient(client) is an object over the Temporal client. await create(Events, *, id, retention=None, auto_close=None, backend=None) creates a Stream that the client owns. get_handle(Events, *, id) and workflow_stream(handle, Events, *, name=None) make no call. A Workflow handle with no first run id makes one Describe call on the Stream's first use, which calls that start together share. With no backend=, a create uses the plugin marked default=True, or else the first one. A backend name that no client plugin has raises StreamUnsupportedError before any call. get_handle and workflow_stream also take backend=, so a client reaches a Stream of its second backend.

subscribe(*topics, from_offset=None, wait_new_records=True, prefixes=()) yields Record, Superseded and Closed, and each Record decodes with its Topic's type from the definition. It has no idle end. create_wait= waits for a Stream that nobody created yet, such as the Stream of a Workflow that just started. Each ClientStream writes as its own Producer. A ClientStream decoded from a payload has no client, and its calls ask for StreamClient.get_handle.

Why?

S64 and S75: the client calls are methods on an object over the client, not free functions or methods of the core client.

How did you test it?

tests/contrib/streams/test_stream_client.py: unit tests on a fake extension for the backend check, a decoded handle and the one Describe call, and live tests on the memory Store and on a scratch redis-server for a client Stream that a Workflow writes to, reads from an offset, by Topic and by prefix, a Workflow's Stream read with create_wait, auto_close, an unresolved handle in comparisons and hashes, and the default backend. pyright, mypy, basedpyright, pydocstyle, ruff.

  • Unit Tests
  • Staging
  • End to End Tests

@moetemp

moetemp commented Oct 25, 2026

Copy link
Copy Markdown
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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant