Skip to content

Add WithContext: context and structured concurrency support - #113

Merged
destel merged 35 commits into
mainfrom
f/scope2
Sep 22, 2026
Merged

destel merged 35 commits into
mainfrom
f/scope2

Conversation

@destel

@destel destel commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Adds WithContext, giving a pipeline structured concurrency semantics similar to errgroup: rill derives the context, a sink cancels it as soon as its outcome is known (typically the first error), and the sink then waits for the pipeline to finish before returning.

ctx, scope := rill.WithContext(ctx)

// Source and other pipeline stages go here

users := rill.Map(ids, 10, func(id int) (*User, error) {
    return getUser(ctx, id) // context-aware
})

err := rill.ForEach(users, 5, func(u *User) error {
    return process(ctx, u)
}, scope)

// Nothing is running anymore

Without the option nothing changes: a sink still returns as soon as its outcome is known and drains the rest in the background.

@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.87%. Comparing base (d20890e) to head (f549696).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #113   +/-   ##
=======================================
  Coverage   99.87%   99.87%           
=======================================
  Files          17       16    -1     
  Lines         806      808    +2     
=======================================
+ Hits          805      807    +2     
  Misses          1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@destel destel changed the title Add WithContext: context and structured concurrency Add WithContext: context and structured concurrency support Sep 21, 2026
@destel
destel merged commit 30c496a into main Sep 22, 2026
6 checks passed
@destel
destel deleted the f/scope2 branch September 22, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant