Skip to content

Add error-aware source stream contract - #10

Merged
tmosleyIII merged 2 commits into
mainfrom
chore/tmosley/modernization-plan-1
Oct 12, 2026
Merged

tmosleyIII merged 2 commits into
mainfrom
chore/tmosley/modernization-plan-1

Conversation

@tmosleyIII

Copy link
Copy Markdown
Contributor

Summary

  • Add OnProduceStream alongside the unchanged legacy OnProduce API, with ordered event draining and a single terminal result.
  • Classify terminal errors into redacted gRPC statuses and mark unrecoverable producer failures unhealthy.
  • Document cooperative cancellation and the v2 removal plan for the legacy handler; add source characterization, cancellation, and synthetic gRPC integration tests.

Verification

  • go test ./...
  • go vet ./...
  • go build ./...
  • go test -race ./pkg/source

Follow-up

  • Tag an SDK release after review, then migrate downstream components.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The exported interface breaks downstream implementations, and request-scoped errors can permanently fail global health.

3 open findings
What changed in this PR

Adds an error-aware source streaming contract with classified terminal errors, cancellation handling, health transitions, and legacy API compatibility.

Changes:

  • Adds ProducerStream, StreamError, and OnProduceStream.
  • Implements ordered draining, cancellation, gRPC status mapping, and health updates.
  • Adds documentation and source-stream integration tests.
File Description
README.md Documents the new producer contract and error mappings.
pkg/​source/​stream.go Defines stream results and error classification.
pkg/​source/​source.go Integrates error-aware streaming into sources.
pkg/​source/​source_test.go Tests compatibility, results, and disconnects.
pkg/​source/​cancellation_test.go Tests cancellation and registration conflicts.
docs/​modernization-plan.md Records modernization requirements and rollout.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/source/source.go Outdated
Comment on lines +46 to +47
// OnProduceStream registers the error-aware producer.
OnProduceStream(producer ProducerStreamFunc) error
Comment thread pkg/source/source.go
Comment on lines +384 to +387
var classified *StreamError
if !errors.Is(err, context.Canceled) && (!errors.As(err, &classified) || classified.Kind != Canceled) {
s.health.SetHealth(flowctl.HealthStatusUnhealthy)
}
Comment thread pkg/source/stream.go Resolved
@tmosleyIII
tmosleyIII merged commit 295e6eb into main Oct 12, 2026
1 check passed
@tmosleyIII
tmosleyIII deleted the chore/tmosley/modernization-plan-1 branch October 12, 2026 11:17
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