Skip to content

Commit

Permalink
gemini: using sync.Once instead of hand crafted version
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Johansson committed Jul 8, 2019
1 parent 014fb7d commit 22a2357
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/gemini/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"sync"

"github.com/briandowns/spinner"
"github.com/pkg/errors"
Expand Down Expand Up @@ -62,21 +63,20 @@ func (r Status) String() string {
}

func sampleStatus(p *Pump, c chan Status, sp *spinner.Spinner, logger *zap.Logger) Status {
failfastDone := sync.Once{}
logger = logger.Named("sample_results")
var testRes Status
done := false
for res := range c {
testRes = res.Merge(&testRes)
if sp != nil {
sp.Suffix = fmt.Sprintf(" Running Gemini... %v", testRes)
}
if testRes.ReadErrors > 0 || testRes.WriteErrors > 0 {
if failFast {
if !done {
done = true
failfastDone.Do(func() {
logger.Warn("Errors detected. Exiting.")
p.Stop()
}
})
}
}
}
Expand Down

0 comments on commit 22a2357

Please sign in to comment.