Skip to content

Commit

Permalink
taskgroup: remove deprecated Listen and Trigger functions
Browse files Browse the repository at this point in the history
Updates tests and examples.
  • Loading branch information
creachadair committed Oct 16, 2024
1 parent 42c8bff commit 038fcca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
4 changes: 2 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ExampleGroup() {
// <done>
}

func ExampleTrigger() {
func ExampleNew_cancel() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down Expand Up @@ -64,7 +64,7 @@ func ExampleTrigger() {
// Output: task 5 failed
}

func ExampleListen() {
func ExampleNew_listen() {
// The taskgroup itself will only report the first non-nil task error, but
// you can use an error listener used to accumulate all of them.
// Calls to the listener are synchronized, so we don't need a lock.
Expand Down
12 changes: 0 additions & 12 deletions taskgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,6 @@ func adaptErrorFunc(ef any) errorFunc {
}
}

// Trigger creates an OnError callback that calls f each time a task reports an
// error. The resulting callback returns task errors unmodified.
//
// Deprecated: Pass f directly to [New] or [Group.OnError].
func Trigger(f func()) any { return f }

// Listen creates an OnError callback that reports each non-nil task error to
// f. The resulting callback returns task errors unmodified.
//
// Deprecated: Pass f directly to [New] or [Group.OnError].
func Listen(f func(error)) any { return f }

// NoError adapts f to a Task that executes f and reports a nil error.
func NoError(f func()) Task { return func() error { f(); return nil } }

Expand Down
4 changes: 2 additions & 2 deletions taskgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func TestCancellation(t *testing.T) {
defer leaktest.Check(t)()

var errs []error
g := taskgroup.New(taskgroup.Listen(func(err error) {
g := taskgroup.New(func(err error) {
errs = append(errs, err)
}))
})

errOther := errors.New("something is wrong")
ctx, cancel := context.WithCancel(context.Background())
Expand Down

0 comments on commit 038fcca

Please sign in to comment.