Skip to content

Conversation

rodrigo-brito
Copy link
Contributor

Example of usage:

runner := NewRunner(tasks...).WithLimit(3)
err := runner.Run(ctx) 

Closes #2
Closes #3

Copy link

@vinicio vinicio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 🌟

Just comments comments. 😬

@codecov-io
Copy link

codecov-io commented Feb 13, 2020

Codecov Report

Merging #7 into master will increase coverage by 11.67%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             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               
Impacted Files Coverage Δ
runner.go 100.00% <100.00%> (ø)
async.go 86.95% <0.00%> (+4.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af9fc37...e0b5055. Read the comment docs.

@rodrigo-brito
Copy link
Contributor Author

@vinicio ♻️

Copy link
Member

@ciceroverneck ciceroverneck left a 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 {
Copy link
Member

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 { // ... }
}

Copy link
Contributor Author

@rodrigo-brito rodrigo-brito Apr 2, 2020

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?

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De boa.

@rodrigo-brito rodrigo-brito merged commit f699bcd into StudioSol:master Apr 3, 2020
@rodrigo-brito rodrigo-brito deleted the task-runner branch April 3, 2020 13:12
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.

Include option to wait all erros finish Include async limit
4 participants