summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-04-07 12:09:48 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-04-07 12:09:48 +0200
commit42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd (patch)
tree3344313b57b160a877044f56eec3d8e3c1c1669c /vendor/github.com/vbauerster
parent64b6a197339e0436168e254ef9caf674ee9ff932 (diff)
downloadpodman-42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd.tar.gz
podman-42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd.tar.bz2
podman-42fcdbf1a85c8e23ccc25a0e7e66b3a51b8f11dd.zip
vendor c/image v5.4.2
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/vbauerster')
-rw-r--r--vendor/github.com/vbauerster/mpb/v4/go.mod10
-rw-r--r--vendor/github.com/vbauerster/mpb/v4/proxyreader.go41
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/.gitignore (renamed from vendor/github.com/vbauerster/mpb/v4/.gitignore)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/.travis.yml (renamed from vendor/github.com/vbauerster/mpb/v4/.travis.yml)6
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/README.md (renamed from vendor/github.com/vbauerster/mpb/v4/README.md)20
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/UNLICENSE (renamed from vendor/github.com/vbauerster/mpb/v4/UNLICENSE)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/bar.go (renamed from vendor/github.com/vbauerster/mpb/v4/bar.go)193
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/bar_filler.go (renamed from vendor/github.com/vbauerster/mpb/v4/bar_filler.go)8
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/bar_option.go (renamed from vendor/github.com/vbauerster/mpb/v4/bar_option.go)48
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer.go (renamed from vendor/github.com/vbauerster/mpb/v4/cwriter/writer.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go (renamed from vendor/github.com/vbauerster/mpb/v4/cwriter/writer_posix.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go (renamed from vendor/github.com/vbauerster/mpb/v4/cwriter/writer_windows.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/any.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/any.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/counters.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/counters.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/decorator.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/decorator.go)26
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/doc.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/doc.go)2
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/elapsed.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/elapsed.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/eta.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/eta.go)18
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/merge.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/merge.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/moving_average.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/moving_average.go)7
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/name.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/name.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/on_complete.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/on_complete.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/percentage.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/percentage.go)2
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/size_type.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/size_type.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/sizeb1000_string.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/sizeb1000_string.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/sizeb1024_string.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/sizeb1024_string.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/speed.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/speed.go)18
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/decor/spinner.go (renamed from vendor/github.com/vbauerster/mpb/v4/decor/spinner.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/doc.go (renamed from vendor/github.com/vbauerster/mpb/v4/doc.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/go.mod10
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/go.sum (renamed from vendor/github.com/vbauerster/mpb/v4/go.sum)8
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/internal/percentage.go (renamed from vendor/github.com/vbauerster/mpb/v4/internal/percentage.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/options.go (renamed from vendor/github.com/vbauerster/mpb/v4/options.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/priority_queue.go (renamed from vendor/github.com/vbauerster/mpb/v4/priority_queue.go)0
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/progress.go (renamed from vendor/github.com/vbauerster/mpb/v4/progress.go)17
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/proxyreader.go90
-rw-r--r--vendor/github.com/vbauerster/mpb/v5/spinner_filler.go (renamed from vendor/github.com/vbauerster/mpb/v4/spinner_filler.go)6
37 files changed, 279 insertions, 251 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v4/go.mod b/vendor/github.com/vbauerster/mpb/v4/go.mod
deleted file mode 100644
index 43b42d496..000000000
--- a/vendor/github.com/vbauerster/mpb/v4/go.mod
+++ /dev/null
@@ -1,10 +0,0 @@
-module github.com/vbauerster/mpb/v4
-
-require (
- github.com/VividCortex/ewma v1.1.1
- github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
- golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6
- golang.org/x/sys v0.0.0-20200217220822-9197077df867 // indirect
-)
-
-go 1.13
diff --git a/vendor/github.com/vbauerster/mpb/v4/proxyreader.go b/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
deleted file mode 100644
index 0e4b51f09..000000000
--- a/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package mpb
-
-import (
- "io"
- "time"
-)
-
-type proxyReader struct {
- io.ReadCloser
- bar *Bar
- iT time.Time
-}
-
-func (prox *proxyReader) Read(p []byte) (n int, err error) {
- n, err = prox.ReadCloser.Read(p)
- if n > 0 {
- prox.bar.IncrBy(n, time.Since(prox.iT))
- prox.iT = time.Now()
- }
- if err == io.EOF {
- go prox.bar.SetTotal(0, true)
- }
- return
-}
-
-type proxyWriterTo struct {
- *proxyReader
- wt io.WriterTo
-}
-
-func (prox *proxyWriterTo) WriteTo(w io.Writer) (n int64, err error) {
- n, err = prox.wt.WriteTo(w)
- if n > 0 {
- prox.bar.IncrInt64(n, time.Since(prox.iT))
- prox.iT = time.Now()
- }
- if err == io.EOF {
- go prox.bar.SetTotal(0, true)
- }
- return
-}
diff --git a/vendor/github.com/vbauerster/mpb/v4/.gitignore b/vendor/github.com/vbauerster/mpb/v5/.gitignore
index 63bd91672..63bd91672 100644
--- a/vendor/github.com/vbauerster/mpb/v4/.gitignore
+++ b/vendor/github.com/vbauerster/mpb/v5/.gitignore
diff --git a/vendor/github.com/vbauerster/mpb/v4/.travis.yml b/vendor/github.com/vbauerster/mpb/v5/.travis.yml
index 997ae32d6..0eb0f2f20 100644
--- a/vendor/github.com/vbauerster/mpb/v4/.travis.yml
+++ b/vendor/github.com/vbauerster/mpb/v5/.travis.yml
@@ -1,11 +1,7 @@
language: go
go:
- - 1.12.x
- - 1.13.x
-
-env:
- - GO111MODULE=on
+ - 1.14.x
script:
- go test -race ./...
diff --git a/vendor/github.com/vbauerster/mpb/v4/README.md b/vendor/github.com/vbauerster/mpb/v5/README.md
index 003fb5987..bfb0c4d18 100644
--- a/vendor/github.com/vbauerster/mpb/v4/README.md
+++ b/vendor/github.com/vbauerster/mpb/v5/README.md
@@ -25,8 +25,8 @@ import (
"math/rand"
"time"
- "github.com/vbauerster/mpb/v4"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5"
+ "github.com/vbauerster/mpb/v5/decor"
)
func main() {
@@ -44,8 +44,7 @@ func main() {
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
// replace ETA decorator with "done" message, OnComplete event
decor.OnComplete(
- // ETA decorator with ewma age of 60, and width reservation of 4
- decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WC{W: 4}), "done",
+ decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
),
),
mpb.AppendDecorators(decor.Percentage()),
@@ -53,17 +52,15 @@ func main() {
// simulating some work
max := 100 * time.Millisecond
for i := 0; i < total; i++ {
- start := time.Now()
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
- // since ewma decorator is used, we need to pass time.Since(start)
- bar.Increment(time.Since(start))
+ bar.Increment()
}
// wait for our bar to complete and flush
p.Wait()
}
```
-#### [Rendering multiple bars](_examples/multiBars//main.go)
+#### [Rendering multiple bars](_examples/multiBars/main.go)
```go
var wg sync.WaitGroup
// pass &wg (optional), so p will wait for it eventually
@@ -94,10 +91,13 @@ func main() {
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
max := 100 * time.Millisecond
for i := 0; i < total; i++ {
+ // start variable is solely for EWMA calculation
+ // EWMA's unit of measure is an iteration's duration
start := time.Now()
time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10)
- // since ewma decorator is used, we need to pass time.Since(start)
- bar.Increment(time.Since(start))
+ bar.Increment()
+ // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
+ bar.DecoratorEwmaUpdate(time.Since(start))
}
}()
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/UNLICENSE b/vendor/github.com/vbauerster/mpb/v5/UNLICENSE
index 68a49daad..68a49daad 100644
--- a/vendor/github.com/vbauerster/mpb/v4/UNLICENSE
+++ b/vendor/github.com/vbauerster/mpb/v5/UNLICENSE
diff --git a/vendor/github.com/vbauerster/mpb/v4/bar.go b/vendor/github.com/vbauerster/mpb/v5/bar.go
index 1828e67a6..1a4c66fe1 100644
--- a/vendor/github.com/vbauerster/mpb/v4/bar.go
+++ b/vendor/github.com/vbauerster/mpb/v5/bar.go
@@ -5,51 +5,43 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"log"
"strings"
"time"
"unicode/utf8"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/decor"
)
-// Filler interface.
-// Bar renders by calling Filler's Fill method. You can literally have
-// any bar kind, by implementing this interface and passing it to the
-// *Progress.Add method.
-type Filler interface {
+// BarFiller interface.
+// Bar renders itself by calling BarFiller's Fill method. You can
+// literally have any bar kind, by implementing this interface and
+// passing it to the *Progress.Add(...) *Bar method.
+type BarFiller interface {
Fill(w io.Writer, width int, stat *decor.Statistics)
}
-// FillerFunc is function type adapter to convert function into Filler.
-type FillerFunc func(w io.Writer, width int, stat *decor.Statistics)
+// BarFillerFunc is function type adapter to convert function into Filler.
+type BarFillerFunc func(w io.Writer, width int, stat *decor.Statistics)
-func (f FillerFunc) Fill(w io.Writer, width int, stat *decor.Statistics) {
+func (f BarFillerFunc) Fill(w io.Writer, width int, stat *decor.Statistics) {
f(w, width, stat)
}
-// WrapFiller interface.
-// If you're implementing custom Filler by wrapping a built-in one,
-// it is necessary to implement this interface to retain functionality
-// of built-in Filler.
-type WrapFiller interface {
- Base() Filler
-}
-
// Bar represents a progress Bar.
type Bar struct {
priority int // used by heap
index int // used by heap
- extendedLines int
- toShutdown bool
- toDrop bool
- noPop bool
- operateState chan func(*bState)
- frameCh chan io.Reader
- syncTableCh chan [][]chan int
- completed chan bool
+ extendedLines int
+ toShutdown bool
+ toDrop bool
+ noPop bool
+ hasEwmaDecorators bool
+ operateState chan func(*bState)
+ frameCh chan io.Reader
+ syncTableCh chan [][]chan int
+ completed chan bool
// cancel is called either by user or on complete event
cancel func()
@@ -66,21 +58,23 @@ type Bar struct {
type extFunc func(in io.Reader, tw int, st *decor.Statistics) (out io.Reader, lines int)
type bState struct {
- baseF Filler
- filler Filler
+ baseF BarFiller
+ filler BarFiller
id int
width int
total int64
current int64
+ lastN int64
+ iterated bool
trimSpace bool
toComplete bool
completeFlushed bool
noPop bool
aDecorators []decor.Decorator
pDecorators []decor.Decorator
- amountReceivers []decor.AmountReceiver
+ averageDecorators []decor.AverageDecorator
+ ewmaDecorators []decor.EwmaDecorator
shutdownListeners []decor.ShutdownListener
- averageAdjusters []decor.AverageAdjuster
bufP, bufB, bufA *bytes.Buffer
extender extFunc
@@ -116,36 +110,13 @@ func newBar(container *Progress, bs *bState) *Bar {
return bar
}
-// RemoveAllPrependers removes all prepend functions.
-func (b *Bar) RemoveAllPrependers() {
- select {
- case b.operateState <- func(s *bState) { s.pDecorators = nil }:
- case <-b.done:
- }
-}
-
-// RemoveAllAppenders removes all append functions.
-func (b *Bar) RemoveAllAppenders() {
- select {
- case b.operateState <- func(s *bState) { s.aDecorators = nil }:
- case <-b.done:
- }
-}
-
// ProxyReader wraps r with metrics required for progress tracking.
+// Panics if r is nil.
func (b *Bar) ProxyReader(r io.Reader) io.ReadCloser {
if r == nil {
- return nil
- }
- rc, ok := r.(io.ReadCloser)
- if !ok {
- rc = ioutil.NopCloser(r)
+ panic("expected non nil io.Reader")
}
- prox := &proxyReader{rc, b, time.Now()}
- if wt, ok := r.(io.WriterTo); ok {
- return &proxyWriterTo{prox, wt}
- }
- return prox
+ return newProxyReader(r, b)
}
// ID returs id of the bar.
@@ -170,8 +141,9 @@ func (b *Bar) Current() int64 {
}
}
-// SetRefill sets refill, if supported by underlying Filler.
-// Useful for resume-able tasks.
+// SetRefill fills bar with refill rune up to amount argument.
+// Given default bar style is "[=>-]<+", refill rune is '+'.
+// To set bar style use mpb.BarStyle(string) BarOption.
func (b *Bar) SetRefill(amount int64) {
type refiller interface {
SetRefill(int64)
@@ -183,18 +155,8 @@ func (b *Bar) SetRefill(amount int64) {
}
}
-// AdjustAverageDecorators updates start time of all average decorators.
-// Useful for resume-able tasks.
-func (b *Bar) AdjustAverageDecorators(startTime time.Time) {
- b.operateState <- func(s *bState) {
- for _, adjuster := range s.averageAdjusters {
- adjuster.AverageAdjust(startTime)
- }
- }
-}
-
// TraverseDecorators traverses all available decorators and calls cb func on each.
-func (b *Bar) TraverseDecorators(cb decor.CBFunc) {
+func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
b.operateState <- func(s *bState) {
for _, decorators := range [...][]decor.Decorator{
s.pDecorators,
@@ -208,7 +170,8 @@ func (b *Bar) TraverseDecorators(cb decor.CBFunc) {
}
// SetTotal sets total dynamically.
-// Set complete to true, to trigger bar complete event now.
+// If total is less or equal to zero it takes progress' current value.
+// If complete is true, complete event will be triggered.
func (b *Bar) SetTotal(total int64, complete bool) {
select {
case b.operateState <- func(s *bState) {
@@ -227,13 +190,12 @@ func (b *Bar) SetTotal(total int64, complete bool) {
}
}
-// SetCurrent sets progress' current to arbitrary amount.
-func (b *Bar) SetCurrent(current int64, wdd ...time.Duration) {
+// SetCurrent sets progress' current to an arbitrary value.
+func (b *Bar) SetCurrent(current int64) {
select {
case b.operateState <- func(s *bState) {
- for _, ar := range s.amountReceivers {
- ar.NextAmount(current-s.current, wdd...)
- }
+ s.iterated = true
+ s.lastN = current - s.current
s.current = current
if s.total > 0 && s.current >= s.total {
s.current = s.total
@@ -245,25 +207,22 @@ func (b *Bar) SetCurrent(current int64, wdd ...time.Duration) {
}
}
-// Increment is a shorthand for b.IncrInt64(1, wdd...).
-func (b *Bar) Increment(wdd ...time.Duration) {
- b.IncrInt64(1, wdd...)
+// Increment is a shorthand for b.IncrInt64(1).
+func (b *Bar) Increment() {
+ b.IncrInt64(1)
}
-// IncrBy is a shorthand for b.IncrInt64(int64(n), wdd...).
-func (b *Bar) IncrBy(n int, wdd ...time.Duration) {
- b.IncrInt64(int64(n), wdd...)
+// IncrBy is a shorthand for b.IncrInt64(int64(n)).
+func (b *Bar) IncrBy(n int) {
+ b.IncrInt64(int64(n))
}
-// IncrInt64 increments progress bar by amount of n. wdd is an optional
-// work duration i.e. time.Since(start), which expected to be passed,
-// if any ewma based decorator is used.
-func (b *Bar) IncrInt64(n int64, wdd ...time.Duration) {
+// IncrInt64 increments progress by amount of n.
+func (b *Bar) IncrInt64(n int64) {
select {
case b.operateState <- func(s *bState) {
- for _, ar := range s.amountReceivers {
- ar.NextAmount(n, wdd...)
- }
+ s.iterated = true
+ s.lastN = n
s.current += n
if s.total > 0 && s.current >= s.total {
s.current = s.total
@@ -275,6 +234,34 @@ func (b *Bar) IncrInt64(n int64, wdd ...time.Duration) {
}
}
+// DecoratorEwmaUpdate updates all EWMA based decorators. Should be
+// called on each iteration, because EWMA's unit of measure is an
+// iteration's duration. Panics if called before *Bar.Incr... family
+// methods.
+func (b *Bar) DecoratorEwmaUpdate(dur time.Duration) {
+ select {
+ case b.operateState <- func(s *bState) {
+ ewmaIterationUpdate(false, s, dur)
+ }:
+ case <-b.done:
+ ewmaIterationUpdate(true, b.cacheState, dur)
+ }
+}
+
+// DecoratorAverageAdjust adjusts all average based decorators. Call
+// if you need to adjust start time of all average based decorators
+// or after progress resume.
+func (b *Bar) DecoratorAverageAdjust(start time.Time) {
+ select {
+ case b.operateState <- func(s *bState) {
+ for _, d := range s.averageDecorators {
+ d.AverageAdjust(start)
+ }
+ }:
+ case <-b.done:
+ }
+}
+
// SetPriority changes bar's order among multiple bars. Zero is highest
// priority, i.e. bar will be on top. If you don't need to set priority
// dynamically, better use BarPriority option.
@@ -368,25 +355,26 @@ func (b *Bar) panicToFrame(termWidth int) io.Reader {
}
func (b *Bar) subscribeDecorators() {
- var amountReceivers []decor.AmountReceiver
+ var averageDecorators []decor.AverageDecorator
+ var ewmaDecorators []decor.EwmaDecorator
var shutdownListeners []decor.ShutdownListener
- var averageAdjusters []decor.AverageAdjuster
b.TraverseDecorators(func(d decor.Decorator) {
- if d, ok := d.(decor.AmountReceiver); ok {
- amountReceivers = append(amountReceivers, d)
+ if d, ok := d.(decor.AverageDecorator); ok {
+ averageDecorators = append(averageDecorators, d)
+ }
+ if d, ok := d.(decor.EwmaDecorator); ok {
+ ewmaDecorators = append(ewmaDecorators, d)
}
if d, ok := d.(decor.ShutdownListener); ok {
shutdownListeners = append(shutdownListeners, d)
}
- if d, ok := d.(decor.AverageAdjuster); ok {
- averageAdjusters = append(averageAdjusters, d)
- }
})
b.operateState <- func(s *bState) {
- s.amountReceivers = amountReceivers
+ s.averageDecorators = averageDecorators
+ s.ewmaDecorators = ewmaDecorators
s.shutdownListeners = shutdownListeners
- s.averageAdjusters = averageAdjusters
}
+ b.hasEwmaDecorators = len(ewmaDecorators) != 0
}
func (b *Bar) refreshTillShutdown() {
@@ -475,3 +463,14 @@ func extractBaseDecorator(d decor.Decorator) decor.Decorator {
}
return d
}
+
+func ewmaIterationUpdate(done bool, s *bState, dur time.Duration) {
+ if !done && !s.iterated {
+ panic("increment required before ewma iteration update")
+ } else {
+ s.iterated = false
+ }
+ for _, d := range s.ewmaDecorators {
+ d.EwmaUpdate(s.lastN, dur)
+ }
+}
diff --git a/vendor/github.com/vbauerster/mpb/v4/bar_filler.go b/vendor/github.com/vbauerster/mpb/v5/bar_filler.go
index fab4aa229..00bf0a494 100644
--- a/vendor/github.com/vbauerster/mpb/v4/bar_filler.go
+++ b/vendor/github.com/vbauerster/mpb/v5/bar_filler.go
@@ -4,8 +4,8 @@ import (
"io"
"unicode/utf8"
- "github.com/vbauerster/mpb/v4/decor"
- "github.com/vbauerster/mpb/v4/internal"
+ "github.com/vbauerster/mpb/v5/decor"
+ "github.com/vbauerster/mpb/v5/internal"
)
const (
@@ -45,8 +45,8 @@ type barFiller struct {
flush func(w io.Writer, bb [][]byte)
}
-// NewBarFiller constucts mpb.Filler, to be used with *Progress.Add(...) *Bar method.
-func NewBarFiller(style string, reverse bool) Filler {
+// NewBarFiller constucts mpb.BarFiller, to be used with *Progress.Add(...) *Bar method.
+func NewBarFiller(style string, reverse bool) BarFiller {
if style == "" {
style = DefaultBarStyle
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/bar_option.go b/vendor/github.com/vbauerster/mpb/v5/bar_option.go
index be0c36215..76f2050f1 100644
--- a/vendor/github.com/vbauerster/mpb/v4/bar_option.go
+++ b/vendor/github.com/vbauerster/mpb/v5/bar_option.go
@@ -4,7 +4,7 @@ import (
"bytes"
"io"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/decor"
)
// BarOption is a function option which changes the default behavior of a bar.
@@ -50,14 +50,9 @@ func BarWidth(width int) BarOption {
}
}
-// BarReplaceOnComplete is deprecated. Use BarParkTo instead.
-func BarReplaceOnComplete(runningBar *Bar) BarOption {
- return BarParkTo(runningBar)
-}
-
-// BarParkTo parks constructed bar into the runningBar. In other words,
-// constructed bar will replace runningBar after it has been completed.
-func BarParkTo(runningBar *Bar) BarOption {
+// BarQueueAfter queues this (being constructed) bar to relplace
+// runningBar after it has been completed.
+func BarQueueAfter(runningBar *Bar) BarOption {
if runningBar == nil {
return nil
}
@@ -66,28 +61,29 @@ func BarParkTo(runningBar *Bar) BarOption {
}
}
-// BarRemoveOnComplete removes bar filler and decorators if any, on
-// complete event.
+// BarRemoveOnComplete removes both bar's filler and its decorators
+// on complete event.
func BarRemoveOnComplete() BarOption {
return func(s *bState) {
s.dropOnComplete = true
}
}
-// BarClearOnComplete clears bar filler only, on complete event.
-func BarClearOnComplete() BarOption {
- return BarOnComplete("")
+// BarFillerClearOnComplete clears bar's filler on complete event.
+// It's shortcut for BarFillerOnComplete("").
+func BarFillerClearOnComplete() BarOption {
+ return BarFillerOnComplete("")
}
-// BarOnComplete replaces bar filler with message, on complete event.
-func BarOnComplete(message string) BarOption {
+// BarFillerOnComplete replaces bar's filler with message, on complete event.
+func BarFillerOnComplete(message string) BarOption {
return func(s *bState) {
- s.filler = makeBarOnCompleteFiller(s.baseF, message)
+ s.filler = makeBarFillerOnComplete(s.baseF, message)
}
}
-func makeBarOnCompleteFiller(filler Filler, message string) Filler {
- return FillerFunc(func(w io.Writer, width int, st *decor.Statistics) {
+func makeBarFillerOnComplete(filler BarFiller, message string) BarFiller {
+ return BarFillerFunc(func(w io.Writer, width int, st *decor.Statistics) {
if st.Completed {
io.WriteString(w, message)
} else {
@@ -107,7 +103,7 @@ func BarPriority(priority int) BarOption {
// BarExtender is an option to extend bar to the next new line, with
// arbitrary output.
-func BarExtender(extender Filler) BarOption {
+func BarExtender(extender BarFiller) BarOption {
if extender == nil {
return nil
}
@@ -116,7 +112,7 @@ func BarExtender(extender Filler) BarOption {
}
}
-func makeExtFunc(extender Filler) extFunc {
+func makeExtFunc(extender BarFiller) extFunc {
buf := new(bytes.Buffer)
nl := []byte("\n")
return func(r io.Reader, tw int, st *decor.Statistics) (io.Reader, int) {
@@ -132,9 +128,9 @@ func TrimSpace() BarOption {
}
}
-// BarStyle overrides mpb.DefaultBarStyle, for example BarStyle("╢▌▌░╟").
-// If you need to override `reverse tip` and `refill rune` set 6th and
-// 7th rune respectively, for example BarStyle("[=>-]<+").
+// BarStyle overrides mpb.DefaultBarStyle which is "[=>-]<+".
+// It's ok to pass string containing just 5 runes, for example "╢▌▌░╟",
+// if you don't need to override '<' (reverse tip) and '+' (refill rune).
func BarStyle(style string) BarOption {
if style == "" {
return nil
@@ -175,7 +171,7 @@ func SpinnerStyle(frames []string) BarOption {
if len(frames) == 0 {
return nil
}
- chk := func(filler Filler) (interface{}, bool) {
+ chk := func(filler BarFiller) (interface{}, bool) {
t, ok := filler.(*spinnerFiller)
return t, ok
}
@@ -189,7 +185,7 @@ func SpinnerStyle(frames []string) BarOption {
// actual type. If you implement your own Filler, so most probably
// you'll need this. See BarStyle or SpinnerStyle for example.
func MakeFillerTypeSpecificBarOption(
- typeChecker func(Filler) (interface{}, bool),
+ typeChecker func(BarFiller) (interface{}, bool),
cb func(interface{}),
) BarOption {
return func(s *bState) {
diff --git a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer.go
index 9ec1ec66b..9ec1ec66b 100644
--- a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_posix.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
index 3fb8b7d75..3fb8b7d75 100644
--- a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_posix.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_posix.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_windows.go b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go
index 712528900..712528900 100644
--- a/vendor/github.com/vbauerster/mpb/v4/cwriter/writer_windows.go
+++ b/vendor/github.com/vbauerster/mpb/v5/cwriter/writer_windows.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/any.go b/vendor/github.com/vbauerster/mpb/v5/decor/any.go
index bf9cf51a5..bf9cf51a5 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/any.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/any.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/counters.go b/vendor/github.com/vbauerster/mpb/v5/decor/counters.go
index 297bf937b..297bf937b 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/counters.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/counters.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/decorator.go b/vendor/github.com/vbauerster/mpb/v5/decor/decorator.go
index 01b67802c..5bca63d52 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/decorator.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/decorator.go
@@ -84,10 +84,17 @@ type Wrapper interface {
Base() Decorator
}
-// AmountReceiver interface.
-// EWMA based decorators need to implement this one.
-type AmountReceiver interface {
- NextAmount(int64, ...time.Duration)
+// EwmaDecorator interface.
+// EWMA based decorators should implement this one.
+type EwmaDecorator interface {
+ EwmaUpdate(int64, time.Duration)
+}
+
+// AverageDecorator interface.
+// Average decorators should implement this interface to provide start
+// time adjustment facility, for resume-able tasks.
+type AverageDecorator interface {
+ AverageAdjust(time.Time)
}
// ShutdownListener interface.
@@ -97,17 +104,8 @@ type ShutdownListener interface {
Shutdown()
}
-// AverageAdjuster interface.
-// Average decorators should implement this interface to provide start
-// time adjustment facility, for resume-able tasks.
-type AverageAdjuster interface {
- AverageAdjust(time.Time)
-}
-
-// CBFunc convenience call back func type.
-type CBFunc func(Decorator)
-
// Global convenience instances of WC with sync width bit set.
+// To be used with multiple bars only, i.e. not effective for single bar usage.
var (
WCSyncWidth = WC{C: DSyncWidth}
WCSyncWidthR = WC{C: DSyncWidthR}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/doc.go b/vendor/github.com/vbauerster/mpb/v5/decor/doc.go
index b595e8015..6d2614451 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/doc.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/doc.go
@@ -1,5 +1,5 @@
/*
- Package decor provides common decorators for "github.com/vbauerster/mpb/v4" module.
+ Package decor provides common decorators for "github.com/vbauerster/mpb/v5" module.
Some decorators returned by this package might have a closure state. It is ok to use
decorators concurrently, unless you share the same decorator among multiple
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/elapsed.go b/vendor/github.com/vbauerster/mpb/v5/decor/elapsed.go
index c9999a3b5..c9999a3b5 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/elapsed.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/elapsed.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/eta.go b/vendor/github.com/vbauerster/mpb/v5/decor/eta.go
index e875e96fa..6cb27a247 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/eta.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/eta.go
@@ -23,11 +23,11 @@ func (f TimeNormalizerFunc) Normalize(src time.Duration) time.Duration {
}
// EwmaETA exponential-weighted-moving-average based ETA decorator.
-// Note that it's necessary to supply bar.Incr* methods with incremental
-// work duration as second argument, in order for this decorator to
-// work correctly. This decorator is a wrapper of MovingAverageETA.
+// For this decorator to work correctly you have to measure each
+// iteration's duration and pass it to the
+// *Bar.DecoratorEwmaUpdate(time.Duration) method after each increment.
func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
- var average MovingAverage
+ var average ewma.MovingAverage
if age == 0 {
average = ewma.NewMovingAverage()
} else {
@@ -46,7 +46,7 @@ func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
//
// `wcc` optional WC config
//
-func MovingAverageETA(style TimeStyle, average MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
+func MovingAverageETA(style TimeStyle, average ewma.MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
d := &movingAverageETA{
WC: initWC(wcc...),
average: average,
@@ -72,12 +72,8 @@ func (d *movingAverageETA) Decor(s *Statistics) string {
return d.FormatMsg(d.producer(remaining))
}
-func (d *movingAverageETA) NextAmount(n int64, wdd ...time.Duration) {
- var workDuration time.Duration
- for _, wd := range wdd {
- workDuration = wd
- }
- durPerItem := float64(workDuration) / float64(n)
+func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) {
+ durPerItem := float64(dur) / float64(n)
if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
return
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/merge.go b/vendor/github.com/vbauerster/mpb/v5/decor/merge.go
index 520f13a7f..520f13a7f 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/merge.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/merge.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/moving_average.go b/vendor/github.com/vbauerster/mpb/v5/decor/moving_average.go
index 6acdb4ace..50ac9c393 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/moving_average.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/moving_average.go
@@ -7,11 +7,6 @@ import (
"github.com/VividCortex/ewma"
)
-// MovingAverage is the interface that computes a moving average over
-// a time-series stream of numbers. The average may be over a window
-// or exponentially decaying.
-type MovingAverage = ewma.MovingAverage
-
type threadSafeMovingAverage struct {
ewma.MovingAverage
mu sync.Mutex
@@ -68,6 +63,6 @@ func (s *medianWindow) Set(value float64) {
}
// NewMedian is fixed last 3 samples median MovingAverage.
-func NewMedian() MovingAverage {
+func NewMedian() ewma.MovingAverage {
return NewThreadSafeMovingAverage(new(medianWindow))
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/name.go b/vendor/github.com/vbauerster/mpb/v5/decor/name.go
index a7d477e07..a7d477e07 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/name.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/name.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/on_complete.go b/vendor/github.com/vbauerster/mpb/v5/decor/on_complete.go
index 0a1526bf5..0a1526bf5 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/on_complete.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/on_complete.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/percentage.go b/vendor/github.com/vbauerster/mpb/v5/decor/percentage.go
index efb2f3ef5..65ca7d318 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/percentage.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/percentage.go
@@ -5,7 +5,7 @@ import (
"io"
"strconv"
- "github.com/vbauerster/mpb/v4/internal"
+ "github.com/vbauerster/mpb/v5/internal"
)
type percentageType float64
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/size_type.go b/vendor/github.com/vbauerster/mpb/v5/decor/size_type.go
index e4b974058..e4b974058 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/size_type.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/size_type.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1000_string.go b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1000_string.go
index 3f32ef715..3f32ef715 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1000_string.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1000_string.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1024_string.go b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1024_string.go
index 9fca66cc7..9fca66cc7 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/sizeb1024_string.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/sizeb1024_string.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/speed.go b/vendor/github.com/vbauerster/mpb/v5/decor/speed.go
index 93f5763e1..8a48e3f52 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/speed.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/speed.go
@@ -28,11 +28,11 @@ func (self *speedFormatter) Format(st fmt.State, verb rune) {
}
// EwmaSpeed exponential-weighted-moving-average based speed decorator.
-// Note that it's necessary to supply bar.Incr* methods with incremental
-// work duration as second argument, in order for this decorator to
-// work correctly. This decorator is a wrapper of MovingAverageSpeed.
+// For this decorator to work correctly you have to measure each
+// iteration's duration and pass it to the
+// *Bar.DecoratorEwmaUpdate(time.Duration) method after each increment.
func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
- var average MovingAverage
+ var average ewma.MovingAverage
if age == 0 {
average = ewma.NewMovingAverage()
} else {
@@ -59,7 +59,7 @@ func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
// unit=UnitKB, format="%.1f" output: "1.0MB/s"
// unit=UnitKB, format="% .1f" output: "1.0 MB/s"
//
-func MovingAverageSpeed(unit int, format string, average MovingAverage, wcc ...WC) Decorator {
+func MovingAverageSpeed(unit int, format string, average ewma.MovingAverage, wcc ...WC) Decorator {
if format == "" {
format = "%.0f"
}
@@ -89,12 +89,8 @@ func (d *movingAverageSpeed) Decor(s *Statistics) string {
return d.FormatMsg(d.msg)
}
-func (d *movingAverageSpeed) NextAmount(n int64, wdd ...time.Duration) {
- var workDuration time.Duration
- for _, wd := range wdd {
- workDuration = wd
- }
- durPerByte := float64(workDuration) / float64(n)
+func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) {
+ durPerByte := float64(dur) / float64(n)
if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
return
}
diff --git a/vendor/github.com/vbauerster/mpb/v4/decor/spinner.go b/vendor/github.com/vbauerster/mpb/v5/decor/spinner.go
index abfb2f76c..abfb2f76c 100644
--- a/vendor/github.com/vbauerster/mpb/v4/decor/spinner.go
+++ b/vendor/github.com/vbauerster/mpb/v5/decor/spinner.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/doc.go b/vendor/github.com/vbauerster/mpb/v5/doc.go
index 5ada71774..5ada71774 100644
--- a/vendor/github.com/vbauerster/mpb/v4/doc.go
+++ b/vendor/github.com/vbauerster/mpb/v5/doc.go
diff --git a/vendor/github.com/vbauerster/mpb/v5/go.mod b/vendor/github.com/vbauerster/mpb/v5/go.mod
new file mode 100644
index 000000000..672191fc8
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v5/go.mod
@@ -0,0 +1,10 @@
+module github.com/vbauerster/mpb/v5
+
+require (
+ github.com/VividCortex/ewma v1.1.1
+ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
+ golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4
+ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
+)
+
+go 1.14
diff --git a/vendor/github.com/vbauerster/mpb/v4/go.sum b/vendor/github.com/vbauerster/mpb/v5/go.sum
index 3d6d33a5c..9a411976a 100644
--- a/vendor/github.com/vbauerster/mpb/v4/go.sum
+++ b/vendor/github.com/vbauerster/mpb/v5/go.sum
@@ -3,11 +3,11 @@ github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmx
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg=
-golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZABEali68eoMFhTZpCjYVA=
+golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200217220822-9197077df867 h1:JoRuNIf+rpHl+VhScRQQvzbHed86tKkqwPMV34T8myw=
-golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
diff --git a/vendor/github.com/vbauerster/mpb/v4/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go
index 7e261cb22..7e261cb22 100644
--- a/vendor/github.com/vbauerster/mpb/v4/internal/percentage.go
+++ b/vendor/github.com/vbauerster/mpb/v5/internal/percentage.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/options.go b/vendor/github.com/vbauerster/mpb/v5/options.go
index 048870284..048870284 100644
--- a/vendor/github.com/vbauerster/mpb/v4/options.go
+++ b/vendor/github.com/vbauerster/mpb/v5/options.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/priority_queue.go b/vendor/github.com/vbauerster/mpb/v5/priority_queue.go
index 29d9bd5a8..29d9bd5a8 100644
--- a/vendor/github.com/vbauerster/mpb/v4/priority_queue.go
+++ b/vendor/github.com/vbauerster/mpb/v5/priority_queue.go
diff --git a/vendor/github.com/vbauerster/mpb/v4/progress.go b/vendor/github.com/vbauerster/mpb/v5/progress.go
index c9b72b0e7..a366b9295 100644
--- a/vendor/github.com/vbauerster/mpb/v4/progress.go
+++ b/vendor/github.com/vbauerster/mpb/v5/progress.go
@@ -12,8 +12,8 @@ import (
"sync"
"time"
- "github.com/vbauerster/mpb/v4/cwriter"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/cwriter"
+ "github.com/vbauerster/mpb/v5/decor"
)
const (
@@ -111,7 +111,7 @@ func (p *Progress) AddSpinner(total int64, alignment SpinnerAlignment, options .
// Add creates a bar which renders itself by provided filler.
// Set total to 0, if you plan to update it later.
// Panics if *Progress instance is done, i.e. called after *Progress.Wait().
-func (p *Progress) Add(total int64, filler Filler, options ...BarOption) *Bar {
+func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar {
if filler == nil {
filler = NewBarFiller(DefaultBarStyle, false)
}
@@ -166,7 +166,7 @@ func (p *Progress) setBarPriority(b *Bar, priority int) {
}
}
-// UpdateBarPriority same as *Bar.SetPriority.
+// UpdateBarPriority same as *Bar.SetPriority(int).
func (p *Progress) UpdateBarPriority(b *Bar, priority int) {
p.setBarPriority(b, priority)
}
@@ -340,7 +340,7 @@ func (s *pState) updateSyncMatrix() {
}
}
-func (s *pState) makeBarState(total int64, filler Filler, options ...BarOption) *bState {
+func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {
bs := &bState{
total: total,
baseF: extractBaseFiller(filler),
@@ -388,8 +388,11 @@ func syncWidth(matrix map[int][]chan int) {
}
}
-func extractBaseFiller(f Filler) Filler {
- if f, ok := f.(WrapFiller); ok {
+func extractBaseFiller(f BarFiller) BarFiller {
+ type wrapper interface {
+ Base() BarFiller
+ }
+ if f, ok := f.(wrapper); ok {
return extractBaseFiller(f.Base())
}
return f
diff --git a/vendor/github.com/vbauerster/mpb/v5/proxyreader.go b/vendor/github.com/vbauerster/mpb/v5/proxyreader.go
new file mode 100644
index 000000000..316f438d7
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v5/proxyreader.go
@@ -0,0 +1,90 @@
+package mpb
+
+import (
+ "io"
+ "io/ioutil"
+ "time"
+)
+
+type proxyReader struct {
+ io.ReadCloser
+ bar *Bar
+}
+
+func (x *proxyReader) Read(p []byte) (int, error) {
+ n, err := x.ReadCloser.Read(p)
+ x.bar.IncrBy(n)
+ if err == io.EOF {
+ go x.bar.SetTotal(0, true)
+ }
+ return n, err
+}
+
+type proxyWriterTo struct {
+ io.ReadCloser // *proxyReader
+ wt io.WriterTo
+ bar *Bar
+}
+
+func (x *proxyWriterTo) WriteTo(w io.Writer) (int64, error) {
+ n, err := x.wt.WriteTo(w)
+ x.bar.IncrInt64(n)
+ if err == io.EOF {
+ go x.bar.SetTotal(0, true)
+ }
+ return n, err
+}
+
+type ewmaProxyReader struct {
+ io.ReadCloser // *proxyReader
+ bar *Bar
+ iT time.Time
+}
+
+func (x *ewmaProxyReader) Read(p []byte) (int, error) {
+ n, err := x.ReadCloser.Read(p)
+ if n > 0 {
+ x.bar.DecoratorEwmaUpdate(time.Since(x.iT))
+ x.iT = time.Now()
+ }
+ return n, err
+}
+
+type ewmaProxyWriterTo struct {
+ io.ReadCloser // *ewmaProxyReader
+ wt io.WriterTo // *proxyWriterTo
+ bar *Bar
+ iT time.Time
+}
+
+func (x *ewmaProxyWriterTo) WriteTo(w io.Writer) (int64, error) {
+ n, err := x.wt.WriteTo(w)
+ if n > 0 {
+ x.bar.DecoratorEwmaUpdate(time.Since(x.iT))
+ x.iT = time.Now()
+ }
+ return n, err
+}
+
+func newProxyReader(r io.Reader, bar *Bar) io.ReadCloser {
+ rc := toReadCloser(r)
+ rc = &proxyReader{rc, bar}
+
+ if wt, isWriterTo := r.(io.WriterTo); bar.hasEwmaDecorators {
+ now := time.Now()
+ rc = &ewmaProxyReader{rc, bar, now}
+ if isWriterTo {
+ rc = &ewmaProxyWriterTo{rc, wt, bar, now}
+ }
+ } else if isWriterTo {
+ rc = &proxyWriterTo{rc, wt, bar}
+ }
+ return rc
+}
+
+func toReadCloser(r io.Reader) io.ReadCloser {
+ if rc, ok := r.(io.ReadCloser); ok {
+ return rc
+ }
+ return ioutil.NopCloser(r)
+}
diff --git a/vendor/github.com/vbauerster/mpb/v4/spinner_filler.go b/vendor/github.com/vbauerster/mpb/v5/spinner_filler.go
index f855be44e..517725fbf 100644
--- a/vendor/github.com/vbauerster/mpb/v4/spinner_filler.go
+++ b/vendor/github.com/vbauerster/mpb/v5/spinner_filler.go
@@ -5,7 +5,7 @@ import (
"strings"
"unicode/utf8"
- "github.com/vbauerster/mpb/v4/decor"
+ "github.com/vbauerster/mpb/v5/decor"
)
// SpinnerAlignment enum.
@@ -27,8 +27,8 @@ type spinnerFiller struct {
alignment SpinnerAlignment
}
-// NewSpinnerFiller constucts mpb.Filler, to be used with *Progress.Add(...) *Bar method.
-func NewSpinnerFiller(style []string, alignment SpinnerAlignment) Filler {
+// NewSpinnerFiller constucts mpb.BarFiller, to be used with *Progress.Add(...) *Bar method.
+func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller {
if len(style) == 0 {
style = DefaultSpinnerStyle
}