fix(deps): update module github.com/vbauerster/mpb/v8 to v8.7.3

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2024-04-09 23:28:27 +00:00
committed by GitHub
parent 3a20c72759
commit 9d18a48803
12 changed files with 73 additions and 106 deletions

2
go.mod
View File

@ -80,7 +80,7 @@ require (
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0 github.com/stretchr/testify v1.9.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/vbauerster/mpb/v8 v8.7.2 github.com/vbauerster/mpb/v8 v8.7.3
github.com/vishvananda/netlink v1.2.1-beta.2 github.com/vishvananda/netlink v1.2.1-beta.2
go.etcd.io/bbolt v1.3.9 go.etcd.io/bbolt v1.3.9
golang.org/x/crypto v0.22.0 golang.org/x/crypto v0.22.0

4
go.sum
View File

@ -579,8 +579,8 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts= github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/vbauerster/mpb/v8 v8.7.2 h1:SMJtxhNho1MV3OuFgS1DAzhANN1Ejc5Ct+0iSaIkB14= github.com/vbauerster/mpb/v8 v8.7.3 h1:n/mKPBav4FFWp5fH4U0lPpXfiOmCEgl5Yx/NM3tKJA0=
github.com/vbauerster/mpb/v8 v8.7.2/go.mod h1:ZFnrjzspgDHoxYLGvxIruiNk73GNTPG4YHgVNpR10VY= github.com/vbauerster/mpb/v8 v8.7.3/go.mod h1:9nFlNpDGVoTmQ4QvNjSLtwLmAFjwmq0XaAF26toHGNM=
github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs= github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs=
github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=

View File

@ -44,12 +44,11 @@ type bState struct {
rmOnComplete bool rmOnComplete bool
noPop bool noPop bool
autoRefresh bool autoRefresh bool
aDecorators []decor.Decorator buffers [3]*bytes.Buffer
pDecorators []decor.Decorator decorators [2][]decor.Decorator
averageDecorators []decor.AverageDecorator averageDecorators []decor.AverageDecorator
ewmaDecorators []decor.EwmaDecorator ewmaDecorators []decor.EwmaDecorator
shutdownListeners []decor.ShutdownListener shutdownListeners []decor.ShutdownListener
buffers [3]*bytes.Buffer
filler BarFiller filler BarFiller
extender extenderFunc extender extenderFunc
renderReq chan<- time.Time renderReq chan<- time.Time
@ -159,10 +158,7 @@ func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
iter := make(chan decor.Decorator) iter := make(chan decor.Decorator)
select { select {
case b.operateState <- func(s *bState) { case b.operateState <- func(s *bState) {
for _, decorators := range [][]decor.Decorator{ for _, decorators := range s.decorators {
s.pDecorators,
s.aDecorators,
} {
for _, d := range decorators { for _, d := range decorators {
iter <- d iter <- d
} }
@ -250,9 +246,7 @@ func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) {
} }
select { select {
case b.operateState <- func(s *bState) { case b.operateState <- func(s *bState) {
if n := current - s.current; n > 0 { s.decoratorEwmaUpdate(current-s.current, iterDur)
s.decoratorEwmaUpdate(n, iterDur)
}
s.current = current s.current = current
if s.triggerComplete && s.current >= s.total { if s.triggerComplete && s.current >= s.total {
s.current = s.total s.current = s.total
@ -411,22 +405,21 @@ func (b *Bar) serve(ctx context.Context, bs *bState) {
func (b *Bar) render(tw int) { func (b *Bar) render(tw int) {
fn := func(s *bState) { fn := func(s *bState) {
var rows []io.Reader frame := new(renderFrame)
stat := newStatistics(tw, s) stat := newStatistics(tw, s)
r, err := s.draw(stat) r, err := s.draw(stat)
if err != nil { if err != nil {
b.frameCh <- &renderFrame{err: err} for _, buf := range s.buffers {
buf.Reset()
}
frame.err = err
b.frameCh <- frame
return return
} }
rows = append(rows, r) frame.rows = append(frame.rows, r)
if s.extender != nil { if s.extender != nil {
rows, err = s.extender(rows, stat) frame.rows, frame.err = s.extender(frame.rows, stat)
if err != nil {
b.frameCh <- &renderFrame{err: err}
return
} }
}
frame := &renderFrame{rows: rows}
if s.completed || s.aborted { if s.completed || s.aborted {
frame.shutdown = s.shutdown frame.shutdown = s.shutdown
frame.rmOnComplete = s.rmOnComplete frame.rmOnComplete = s.rmOnComplete
@ -484,18 +477,7 @@ func (b *Bar) wSyncTable() syncTable {
} }
} }
func (s *bState) draw(stat decor.Statistics) (io.Reader, error) { func (s *bState) draw(stat decor.Statistics) (_ io.Reader, err error) {
r, err := s.drawImpl(stat)
if err != nil {
for _, b := range s.buffers {
b.Reset()
}
return nil, err
}
return io.MultiReader(r, strings.NewReader("\n")), nil
}
func (s *bState) drawImpl(stat decor.Statistics) (io.Reader, error) {
decorFiller := func(buf *bytes.Buffer, decorators []decor.Decorator) (err error) { decorFiller := func(buf *bytes.Buffer, decorators []decor.Decorator) (err error) {
for _, d := range decorators { for _, d := range decorators {
// need to call Decor in any case becase of width synchronization // need to call Decor in any case becase of width synchronization
@ -515,45 +497,45 @@ func (s *bState) drawImpl(stat decor.Statistics) (io.Reader, error) {
return err return err
} }
bufP, bufB, bufA := s.buffers[0], s.buffers[1], s.buffers[2] for i, buf := range s.buffers[:2] {
err = decorFiller(buf, s.decorators[i])
err := eitherError(decorFiller(bufP, s.pDecorators), decorFiller(bufA, s.aDecorators))
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
if !s.trimSpace && stat.AvailableWidth >= 2 { spaces := []io.Reader{
stat.AvailableWidth -= 2 strings.NewReader(" "),
writeFiller := func(buf *bytes.Buffer) error { strings.NewReader(" "),
return s.filler.Fill(buf, stat)
}
for _, fn := range []func(*bytes.Buffer) error{
writeSpace,
writeFiller,
writeSpace,
} {
if err := fn(bufB); err != nil {
return nil, err
} }
if s.trimSpace || stat.AvailableWidth < 2 {
for _, r := range spaces {
_, _ = io.Copy(io.Discard, r)
} }
} else { } else {
err := s.filler.Fill(bufB, stat) stat.AvailableWidth -= 2
}
err = s.filler.Fill(s.buffers[2], stat)
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
return io.MultiReader(bufP, bufB, bufA), nil return io.MultiReader(
s.buffers[0],
spaces[0],
s.buffers[2],
spaces[1],
s.buffers[1],
strings.NewReader("\n"),
), nil
} }
func (s *bState) wSyncTable() (table syncTable) { func (s *bState) wSyncTable() (table syncTable) {
var count int var count int
var row []chan int var row []chan int
for i, decorators := range [][]decor.Decorator{ for i, decorators := range s.decorators {
s.pDecorators,
s.aDecorators,
} {
for _, d := range decorators { for _, d := range decorators {
if ch, ok := d.Sync(); ok { if ch, ok := d.Sync(); ok {
row = append(row, ch) row = append(row, ch)
@ -640,16 +622,3 @@ func unwrap(d decor.Decorator) decor.Decorator {
} }
return d return d
} }
func writeSpace(buf *bytes.Buffer) error {
return buf.WriteByte(' ')
}
func eitherError(errors ...error) error {
for _, err := range errors {
if err != nil {
return err
}
}
return nil
}

View File

@ -20,19 +20,19 @@ func inspect(decorators []decor.Decorator) (dest []decor.Decorator) {
return return
} }
// AppendDecorators let you inject decorators to the bar's right side.
func AppendDecorators(decorators ...decor.Decorator) BarOption {
decorators = inspect(decorators)
return func(s *bState) {
s.aDecorators = decorators
}
}
// PrependDecorators let you inject decorators to the bar's left side. // PrependDecorators let you inject decorators to the bar's left side.
func PrependDecorators(decorators ...decor.Decorator) BarOption { func PrependDecorators(decorators ...decor.Decorator) BarOption {
decorators = inspect(decorators) decorators = inspect(decorators)
return func(s *bState) { return func(s *bState) {
s.pDecorators = decorators s.decorators[0] = decorators
}
}
// AppendDecorators let you inject decorators to the bar's right side.
func AppendDecorators(decorators ...decor.Decorator) BarOption {
decorators = inspect(decorators)
return func(s *bState) {
s.decorators[1] = decorators
} }
} }
@ -129,11 +129,11 @@ func makeExtenderFunc(filler BarFiller, rev bool) extenderFunc {
for { for {
b, err := buf.ReadBytes('\n') b, err := buf.ReadBytes('\n')
if err != nil { if err != nil {
buf.Reset()
break break
} }
rows = append(rows, bytes.NewReader(b)) rows = append(rows, bytes.NewReader(b))
} }
buf.Reset()
return rows, err return rows, err
} }

View File

@ -85,7 +85,7 @@ type Synchronizer interface {
// in order to format string according to decor.WC settings. // in order to format string according to decor.WC settings.
// No need to implement manually as long as decor.WC is embedded. // No need to implement manually as long as decor.WC is embedded.
type Formatter interface { type Formatter interface {
Format(string) (str string, viewWidth int) Format(string) (_ string, width int)
} }
// Wrapper interface. // Wrapper interface.
@ -138,17 +138,17 @@ type WC struct {
// Format should be called by any Decorator implementation. // Format should be called by any Decorator implementation.
// Returns formatted string and its view (visual) width. // Returns formatted string and its view (visual) width.
func (wc WC) Format(str string) (string, int) { func (wc WC) Format(str string) (string, int) {
viewWidth := runewidth.StringWidth(str) width := runewidth.StringWidth(str)
if wc.W > viewWidth { if wc.W > width {
viewWidth = wc.W width = wc.W
} else if (wc.C & DextraSpace) != 0 { } else if (wc.C & DextraSpace) != 0 {
viewWidth++ width++
} }
if (wc.C & DSyncWidth) != 0 { if (wc.C & DSyncWidth) != 0 {
wc.wsync <- viewWidth wc.wsync <- width
viewWidth = <-wc.wsync width = <-wc.wsync
} }
return wc.fill(str, viewWidth), viewWidth return wc.fill(str, width), width
} }
// Init initializes width related config. // Init initializes width related config.

View File

@ -39,7 +39,7 @@ func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
} else { } else {
average = ewma.NewMovingAverage(age) average = ewma.NewMovingAverage(age)
} }
return MovingAverageETA(style, NewThreadSafeMovingAverage(average), nil, wcc...) return MovingAverageETA(style, average, nil, wcc...)
} }
// MovingAverageETA decorator relies on MovingAverage implementation to calculate its average. // MovingAverageETA decorator relies on MovingAverage implementation to calculate its average.

View File

@ -70,5 +70,5 @@ func (s *medianWindow) Set(value float64) {
// NewMedian is fixed last 3 samples median MovingAverage. // NewMedian is fixed last 3 samples median MovingAverage.
func NewMedian() ewma.MovingAverage { func NewMedian() ewma.MovingAverage {
return NewThreadSafeMovingAverage(new(medianWindow)) return new(medianWindow)
} }

View File

@ -56,7 +56,7 @@ type onAbortMetaWrapper struct {
} }
func (d onAbortMetaWrapper) Decor(s Statistics) (string, int) { func (d onAbortMetaWrapper) Decor(s Statistics) (string, int) {
if s.Completed { if s.Aborted {
str, width := d.Decorator.Decor(s) str, width := d.Decorator.Decor(s)
return d.fn(str), width return d.fn(str), width
} }

View File

@ -46,7 +46,7 @@ func EwmaSpeed(unit interface{}, format string, age float64, wcc ...WC) Decorato
} else { } else {
average = ewma.NewMovingAverage(age) average = ewma.NewMovingAverage(age)
} }
return MovingAverageSpeed(unit, format, NewThreadSafeMovingAverage(average), wcc...) return MovingAverageSpeed(unit, format, average, wcc...)
} }
// MovingAverageSpeed decorator relies on MovingAverage implementation // MovingAverageSpeed decorator relies on MovingAverage implementation
@ -82,7 +82,7 @@ type movingAverageSpeed struct {
zDur time.Duration zDur time.Duration
} }
func (d *movingAverageSpeed) Decor(s Statistics) (string, int) { func (d *movingAverageSpeed) Decor(_ Statistics) (string, int) {
var str string var str string
// ewma implementation may return 0 before accumulating certain number of samples // ewma implementation may return 0 before accumulating certain number of samples
if v := d.average.Value(); v != 0 { if v := d.average.Value(); v != 0 {

View File

@ -3,7 +3,7 @@ package internal
// CheckRequestedWidth checks that requested width doesn't overflow // CheckRequestedWidth checks that requested width doesn't overflow
// available width // available width
func CheckRequestedWidth(requested, available int) int { func CheckRequestedWidth(requested, available int) int {
if requested < 1 || requested >= available { if requested < 1 || requested > available {
return available return available
} }
return requested return requested

View File

@ -14,9 +14,7 @@ import (
"github.com/vbauerster/mpb/v8/decor" "github.com/vbauerster/mpb/v8/decor"
) )
const ( const defaultRefreshRate = 150 * time.Millisecond
defaultRefreshRate = 150 * time.Millisecond
)
// DoneError represents use after `(*Progress).Wait()` error. // DoneError represents use after `(*Progress).Wait()` error.
var DoneError = fmt.Errorf("%T instance can't be reused after %[1]T.Wait()", (*Progress)(nil)) var DoneError = fmt.Errorf("%T instance can't be reused after %[1]T.Wait()", (*Progress)(nil))
@ -467,9 +465,9 @@ func (s pState) makeBarState(total int64, filler BarFiller, options ...BarOption
} }
} }
for i := 0; i < len(bs.buffers); i++ { bs.buffers[0] = bytes.NewBuffer(make([]byte, 0, 128)) // prepend
bs.buffers[i] = bytes.NewBuffer(make([]byte, 0, 512)) bs.buffers[1] = bytes.NewBuffer(make([]byte, 0, 128)) // append
} bs.buffers[2] = bytes.NewBuffer(make([]byte, 0, 256)) // filler
return bs return bs
} }

2
vendor/modules.txt vendored
View File

@ -1079,7 +1079,7 @@ github.com/ulikunitz/xz/lzma
github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/archive/tar
github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/asm
github.com/vbatts/tar-split/tar/storage github.com/vbatts/tar-split/tar/storage
# github.com/vbauerster/mpb/v8 v8.7.2 # github.com/vbauerster/mpb/v8 v8.7.3
## explicit; go 1.17 ## explicit; go 1.17
github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8
github.com/vbauerster/mpb/v8/cwriter github.com/vbauerster/mpb/v8/cwriter