diff options
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/decor')
6 files changed, 39 insertions, 28 deletions
diff --git a/vendor/github.com/vbauerster/mpb/decor/counters.go b/vendor/github.com/vbauerster/mpb/decor/counters.go index e4161dc4b..7d581eefb 100644 --- a/vendor/github.com/vbauerster/mpb/decor/counters.go +++ b/vendor/github.com/vbauerster/mpb/decor/counters.go @@ -141,12 +141,14 @@ func CountersNoUnit(pairFormat string, wcc ...WC) Decorator { return Counters(0, pairFormat, wcc...) } -// CountersKibiByte is a wrapper around Counters with predefined unit UnitKiB (bytes/1024). +// CountersKibiByte is a wrapper around Counters with predefined unit +// UnitKiB (bytes/1024). func CountersKibiByte(pairFormat string, wcc ...WC) Decorator { return Counters(UnitKiB, pairFormat, wcc...) } -// CountersKiloByte is a wrapper around Counters with predefined unit UnitKB (bytes/1000). +// CountersKiloByte is a wrapper around Counters with predefined unit +// UnitKB (bytes/1000). func CountersKiloByte(pairFormat string, wcc ...WC) Decorator { return Counters(UnitKB, pairFormat, wcc...) } diff --git a/vendor/github.com/vbauerster/mpb/decor/decorator.go b/vendor/github.com/vbauerster/mpb/decor/decorator.go index 6aaf6c830..2fe40aea6 100644 --- a/vendor/github.com/vbauerster/mpb/decor/decorator.go +++ b/vendor/github.com/vbauerster/mpb/decor/decorator.go @@ -31,8 +31,12 @@ const ( DSyncSpaceR = DSyncWidth | DextraSpace | DidentRight ) +// TimeStyle enum. +type TimeStyle int + +// TimeStyle kinds. const ( - ET_STYLE_GO = iota + ET_STYLE_GO TimeStyle = iota ET_STYLE_HHMMSS ET_STYLE_HHMM ET_STYLE_MMSS @@ -47,35 +51,37 @@ type Statistics struct { } // Decorator interface. -// A decorator must implement this interface, in order to be used with mpb library. +// A decorator must implement this interface, in order to be used with +// mpb library. type Decorator interface { Decor(*Statistics) string Syncable } // Syncable interface. -// All decorators implement this interface implicitly. -// Its Syncable method exposes width sync channel, if sync is enabled. +// All decorators implement this interface implicitly. Its Syncable +// method exposes width sync channel, if sync is enabled. type Syncable interface { Syncable() (bool, chan int) } // OnCompleteMessenger interface. -// Decorators implementing this interface suppose to return provided string on complete event. +// Decorators implementing this interface suppose to return provided +// string on complete event. type OnCompleteMessenger interface { OnCompleteMessage(string) } // AmountReceiver interface. -// If decorator needs to receive increment amount, -// so this is the right interface to implement. +// If decorator needs to receive increment amount, so this is the right +// interface to implement. type AmountReceiver interface { NextAmount(int, ...time.Duration) } // ShutdownListener interface. -// If decorator needs to be notified once upon bar shutdown event, -// so this is the right interface to implement. +// If decorator needs to be notified once upon bar shutdown event, so +// this is the right interface to implement. type ShutdownListener interface { Shutdown() } @@ -90,6 +96,7 @@ var ( // WC is a struct with two public fields W and C, both of int type. // W represents width and C represents bit set of width related config. +// A decorator should embed WC, in order to become Syncable. type WC struct { W int C int @@ -126,12 +133,13 @@ func (wc *WC) Init() { } } +// Syncable is implementation of Syncable interface. func (wc *WC) Syncable() (bool, chan int) { return (wc.C & DSyncWidth) != 0, wc.wsync } -// OnComplete returns decorator, which wraps provided decorator, with sole -// purpose to display provided message on complete event. +// OnComplete returns decorator, which wraps provided decorator, with +// sole purpose to display provided message on complete event. // // `decorator` Decorator to wrap // diff --git a/vendor/github.com/vbauerster/mpb/decor/elapsed.go b/vendor/github.com/vbauerster/mpb/decor/elapsed.go index 649d40a30..b2e75852c 100644 --- a/vendor/github.com/vbauerster/mpb/decor/elapsed.go +++ b/vendor/github.com/vbauerster/mpb/decor/elapsed.go @@ -10,7 +10,7 @@ import ( // `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS] // // `wcc` optional WC config -func Elapsed(style int, wcc ...WC) Decorator { +func Elapsed(style TimeStyle, wcc ...WC) Decorator { var wc WC for _, widthConf := range wcc { wc = widthConf @@ -26,7 +26,7 @@ func Elapsed(style int, wcc ...WC) Decorator { type elapsedDecorator struct { WC - style int + style TimeStyle startTime time.Time msg string completeMsg *string diff --git a/vendor/github.com/vbauerster/mpb/decor/eta.go b/vendor/github.com/vbauerster/mpb/decor/eta.go index 44a1f03ea..e8dc979b4 100644 --- a/vendor/github.com/vbauerster/mpb/decor/eta.go +++ b/vendor/github.com/vbauerster/mpb/decor/eta.go @@ -6,7 +6,6 @@ import ( "time" "github.com/VividCortex/ewma" - "github.com/vbauerster/mpb/internal" ) type TimeNormalizer func(time.Duration) time.Duration @@ -18,7 +17,7 @@ type TimeNormalizer func(time.Duration) time.Duration // `age` is the previous N samples to average over. // // `wcc` optional WC config -func EwmaETA(style int, age float64, wcc ...WC) Decorator { +func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator { return MovingAverageETA(style, ewma.NewMovingAverage(age), NopNormalizer(), wcc...) } @@ -31,7 +30,7 @@ func EwmaETA(style int, age float64, wcc ...WC) Decorator { // `normalizer` available implementations are [NopNormalizer|FixedIntervalTimeNormalizer|MaxTolerateTimeNormalizer] // // `wcc` optional WC config -func MovingAverageETA(style int, average MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator { +func MovingAverageETA(style TimeStyle, average MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator { var wc WC for _, widthConf := range wcc { wc = widthConf @@ -48,7 +47,7 @@ func MovingAverageETA(style int, average MovingAverage, normalizer TimeNormalize type movingAverageETA struct { WC - style int + style TimeStyle average ewma.MovingAverage completeMsg *string normalizer TimeNormalizer @@ -59,7 +58,7 @@ func (d *movingAverageETA) Decor(st *Statistics) string { return d.FormatMsg(*d.completeMsg) } - v := internal.Round(d.average.Value()) + v := math.Round(d.average.Value()) remaining := d.normalizer(time.Duration((st.Total - st.Current) * int64(v))) hours := int64((remaining / time.Hour) % 60) minutes := int64((remaining / time.Minute) % 60) @@ -105,7 +104,7 @@ func (d *movingAverageETA) OnCompleteMessage(msg string) { // `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS] // // `wcc` optional WC config -func AverageETA(style int, wcc ...WC) Decorator { +func AverageETA(style TimeStyle, wcc ...WC) Decorator { var wc WC for _, widthConf := range wcc { wc = widthConf @@ -121,7 +120,7 @@ func AverageETA(style int, wcc ...WC) Decorator { type averageETA struct { WC - style int + style TimeStyle startTime time.Time completeMsg *string } @@ -133,7 +132,7 @@ func (d *averageETA) Decor(st *Statistics) string { var str string timeElapsed := time.Since(d.startTime) - v := internal.Round(float64(timeElapsed) / float64(st.Current)) + v := math.Round(float64(timeElapsed) / float64(st.Current)) if math.IsInf(v, 0) || math.IsNaN(v) { v = 0 } diff --git a/vendor/github.com/vbauerster/mpb/decor/moving-average.go b/vendor/github.com/vbauerster/mpb/decor/moving-average.go index f9596a27f..fcd268923 100644 --- a/vendor/github.com/vbauerster/mpb/decor/moving-average.go +++ b/vendor/github.com/vbauerster/mpb/decor/moving-average.go @@ -6,9 +6,9 @@ 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. +// 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 interface { Add(float64) Value() float64 @@ -57,7 +57,8 @@ func (s *medianEwma) Add(v float64) { s.count++ } -// NewMedianEwma is ewma based MovingAverage, which gets its values from median MovingAverage. +// NewMedianEwma is ewma based MovingAverage, which gets its values +// from median MovingAverage. func NewMedianEwma(age ...float64) MovingAverage { return &medianEwma{ MovingAverage: ewma.NewMovingAverage(age...), diff --git a/vendor/github.com/vbauerster/mpb/decor/speed.go b/vendor/github.com/vbauerster/mpb/decor/speed.go index 395e5d04d..74658ce41 100644 --- a/vendor/github.com/vbauerster/mpb/decor/speed.go +++ b/vendor/github.com/vbauerster/mpb/decor/speed.go @@ -137,7 +137,8 @@ func EwmaSpeed(unit int, unitFormat string, age float64, wcc ...WC) Decorator { return MovingAverageSpeed(unit, unitFormat, ewma.NewMovingAverage(age), wcc...) } -// MovingAverageSpeed decorator relies on MovingAverage implementation to calculate its average. +// MovingAverageSpeed decorator relies on MovingAverage implementation +// to calculate its average. // // `unit` one of [0|UnitKiB|UnitKB] zero for no unit // |