Skip to content

Deprecate Split2 and OrderedSplit2#89

Merged
destel merged 2 commits into
mainfrom
f/remove-split2
Jul 11, 2026
Merged

Deprecate Split2 and OrderedSplit2#89
destel merged 2 commits into
mainfrom
f/remove-split2

Conversation

@destel

@destel destel commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Since the introduction of Tee in v0.8, splitting no longer needs a dedicated operation — it can be composed from existing ones, and the composition isn't limited to two branches.

When the predicate is a simple pure check, splitting is just Tee + Filter on each branch:

adults, minors := rill.Tee(users)
adults = rill.Filter(adults, 1, func(u User) (bool, error) { return u.Age >= 18, nil })
minors = rill.Filter(minors, 1, func(u User) (bool, error) { return u.Age < 18, nil })

When the predicate is expensive, stateful, or can fail, evaluate it once per item before Tee, tagging each item with the decision and routing on the tag:

type Decision struct {
    Value    User
    Decision bool
}

tagged := rill.Map(users, n, func(u User) (Decision, error) {
    ok, err := isAdult(u)
    return Decision{Value: u, Decision: ok}, err
})

tagged1, tagged2 := rill.Tee(tagged)
adults := rill.FilterMap(tagged1, 1, func(d Decision) (User, bool, error) { return d.Value, d.Decision, nil })
minors := rill.FilterMap(tagged2, 1, func(d Decision) (User, bool, error) { return d.Value, !d.Decision, nil })

The same pattern extends to n-way splitting by tagging with an index or key instead of a bool.

The deprecated functions are now implemented as exactly this composition, so the existing Split2 tests validate the migration path until removal in v1.0.

Also mentions the upcoming v1.0 removal in DrainNB's deprecation notice.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.25%. Comparing base (f825caa) to head (c9e840f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
- Coverage   99.28%   99.25%   -0.04%     
==========================================
  Files          15       15              
  Lines         697      667      -30     
==========================================
- Hits          692      662      -30     
  Misses          5        5              

☔ 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 merged commit 134cf19 into main Jul 11, 2026
6 checks passed
@destel destel deleted the f/remove-split2 branch July 11, 2026 14:57
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