Skip to content

Commit

Permalink
Merge pull request #3 from gregwebs/concurrent-error-slice
Browse files Browse the repository at this point in the history
return []error rather than error
  • Loading branch information
gregwebs authored Oct 29, 2024
2 parents 352789c + 2cf6934 commit 7b7812c
Show file tree
Hide file tree
Showing 5 changed files with 371 additions and 237 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ parallelism in Go using generics

## Error handling

This library relies on go-recovery to trap panics that occur in go routines.
go-recovery by default will log panics but can be configured to send them to an error monitoring service.
This library relies on go-recovery to trap panics that occur in user supplied work functions.
This library does have unhandled panics, but only in places where panics should never occur.
Errors and panics are written to an error channel for maximum flexibility.
There are helpers for common patterns for dealing with errors:

For maximum flexibility with error handling, many of the parallel functions return an error channel.
Any errors that occur in work functions will be put into the error channel.
There are helpers for common patterns for dealing with the errors:

* CollectErrors
* CancelAfterFirstError
* CollectErrors (wait and convert to a slice)
* CancelAfterFirstError (cancel and wait and convert to a slice)
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ go 1.19
require (
github.com/gregwebs/go-recovery v0.2.1
github.com/stretchr/testify v1.8.1
go.uber.org/multierr v1.9.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gregwebs/errors v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
Loading

0 comments on commit 7b7812c

Please sign in to comment.