-
Notifications
You must be signed in to change notification settings - Fork 18
Include task runner #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
167d74b
to
094a12f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🌟
Just comments comments. 😬
094a12f
to
9d9b0d8
Compare
Codecov Report
@@ Coverage Diff @@
## master #7 +/- ##
===========================================
+ Coverage 82.60% 94.28% +11.67%
===========================================
Files 1 2 +1
Lines 46 105 +59
===========================================
+ Hits 38 99 +61
+ Misses 5 3 -2
Partials 3 3
Continue to review full report at Codecov.
|
@vinicio ♻️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O teste do cancel não está efetivo. Mesmo que o cancel não funcionar ele vai passar.
} | ||
|
||
// AllErrors returns all errors reported by functions | ||
func (r *Runner) AllErrors() []error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retornar todos os erros no mesmo obj que responda a interface de erro, e depois tratar usando error.As
não seria mais idiomático?
err := async.NewRunner(func(context.Context) error {
return errors.New("1")
},
func(context.Context) error {
return errors.New("2")
}).Run(ctx)
var aerr *async.MultiErr
if errors.As(err, &aerr) {
for _, err := range aerr { // ... }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ciceroverneck O comportamento atual retorna o primeiro erro que ocorrer sem alterar ele. Nesse formato o err == ErrExample
não funcionaria mais. O usuário é obrigado a usar o errors.Is
ou errrors.As
. Vai quebrar muito código nosso, o que acha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esse AllErrors
em tese seria apenas mais uma alternativa caso ele chamar o Runner com a opção WaitErrors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De boa.
Example of usage:
Closes #2
Closes #3