Skip to content

Add workflow streams sample#490

Merged
brianstrauch merged 6 commits into
mainfrom
workflow-streams-sample
Jun 17, 2026
Merged

Add workflow streams sample#490
brianstrauch merged 6 commits into
mainfrom
workflow-streams-sample

Conversation

@brianstrauch

@brianstrauch brianstrauch commented Jun 3, 2026

Copy link
Copy Markdown
Member

What

Adds a Go sample for the go.temporal.io/sdk/contrib/workflowstreams package — a durable publish/subscribe log hosted inside a workflow (external code publishes to named topics via signals, subscribers long-poll via updates, a query exposes the current offset). It mirrors the samples-typescript PR #470 and the samples-python workflow_streams samples.

Five scenarios, each with its own runner under workflowstreams/:

  1. publisher — basic publish/subscribe: an order workflow publishes status events while an activity publishes progress events to the same stream; a subscriber consumes both topics.
  2. reconnecting — a subscriber reads a few events, disconnects, and a new client resumes from the saved offset with no gaps or duplicates.
  3. external-publisher — a hub workflow just hosts the stream; an external publisher pushes news in and signals it to close.
  4. truncating-ticker — the workflow periodically truncates its log to bound history; a late subscriber resuming from a truncated offset is fast-forwarded to the current base offset.
  5. llm — an activity makes a streaming OpenAI call and republishes each token delta; the subscriber renders incrementally and resets on retries. Runs on its own worker/task queue (llmworker) and needs OPENAI_API_KEY.

Includes testsuite unit tests for all five workflows plus a StartDevServer integration test for scenario 1 (the only path that exercises publish-from-activity + subscribe end to end).

Testing

All scenarios were run end to end against a local dev server. gofmt, go vet, staticcheck, errcheck, workflowcheck, and go test -race all pass for the new package.

🤖 Generated with Claude Code

Add a Go sample for the workflowstreams contrib package, mirroring the
TypeScript and Python workflow streams samples. Covers five scenarios:
basic publish/subscribe, a reconnecting subscriber, an external publisher,
a truncating ticker, and LLM token streaming.

The sample currently depends on the unreleased
go.temporal.io/sdk/contrib/workflowstreams package and a reserved-name
carve-out in the SDK, both wired up via local replace directives pointing
at a sibling sdk-go checkout. Those replaces must be dropped once tagged
SDK and contrib releases ship.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@brianstrauch brianstrauch requested a review from a team as a code owner June 3, 2026 21:32
Drop the local sdk-go replace directives now that the contrib package is
tagged. NewStream was renamed to NewWorkflowStream in the released API.
The core SDK is pinned to a pseudo-version of main for the
__temporal_workflow_stream_ reserved-name carve-out, which is not in a
tagged SDK release yet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@yuandrew yuandrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM, let's wait til a Go SDK release before we merge, since we don't really want go.mod referencing a non-released commit

Comment thread workflowstreams/README.md Outdated
Comment thread workflowstreams/README.md Outdated
Comment thread workflowstreams/README.md Outdated
brianstrauch and others added 4 commits June 12, 2026 09:47
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@brianstrauch brianstrauch requested a review from yuandrew June 17, 2026 21:02
@brianstrauch brianstrauch enabled auto-merge (squash) June 17, 2026 21:05

@yuandrew yuandrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😄

@brianstrauch brianstrauch merged commit 76d6137 into main Jun 17, 2026
5 checks passed
@brianstrauch brianstrauch deleted the workflow-streams-sample branch June 17, 2026 23:00
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.

2 participants