Merge pull request #18214 from containers/renovate/github.com-vbauerster-mpb-v8-8.x
fix(deps): update module github.com/vbauerster/mpb/v8 to v8.4.0
This commit is contained in:
commit
625ff8fc3e
2
go.mod
2
go.mod
|
|
@ -58,7 +58,7 @@ require (
|
||||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
|
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
|
||||||
github.com/uber/jaeger-client-go v2.30.0+incompatible
|
github.com/uber/jaeger-client-go v2.30.0+incompatible
|
||||||
github.com/ulikunitz/xz v0.5.11
|
github.com/ulikunitz/xz v0.5.11
|
||||||
github.com/vbauerster/mpb/v8 v8.3.0
|
github.com/vbauerster/mpb/v8 v8.4.0
|
||||||
github.com/vishvananda/netlink v1.2.1-beta.2
|
github.com/vishvananda/netlink v1.2.1-beta.2
|
||||||
go.etcd.io/bbolt v1.3.7
|
go.etcd.io/bbolt v1.3.7
|
||||||
golang.org/x/net v0.9.0
|
golang.org/x/net v0.9.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -987,8 +987,8 @@ github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN
|
||||||
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
|
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
|
||||||
github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck=
|
github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck=
|
||||||
github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY=
|
github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY=
|
||||||
github.com/vbauerster/mpb/v8 v8.3.0 h1:xw2eMJ6v5NP8Rd7yOVzU6OqnRPrS1yWAoLTrWe7W4Nc=
|
github.com/vbauerster/mpb/v8 v8.4.0 h1:Jq2iNA7T6SydpMVOwaT+2OBWlXS9Th8KEvBqeu5eeTo=
|
||||||
github.com/vbauerster/mpb/v8 v8.3.0/go.mod h1:bngtYUAu25QGxcYYglsF6oyoHlC9Yhh582xF9LjfmL4=
|
github.com/vbauerster/mpb/v8 v8.4.0/go.mod h1:vjp3hSTuCtR+x98/+2vW3eZ8XzxvGoP8CPseHMhiPyc=
|
||||||
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
|
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
|
||||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||||
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
|
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,8 @@ func main() {
|
||||||
mpb.AppendDecorators(
|
mpb.AppendDecorators(
|
||||||
// replace ETA decorator with "done" message, OnComplete event
|
// replace ETA decorator with "done" message, OnComplete event
|
||||||
decor.OnComplete(
|
decor.OnComplete(
|
||||||
// ETA decorator with ewma age of 60
|
// ETA decorator with ewma age of 30
|
||||||
decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncWidth), "done",
|
decor.EwmaETA(decor.ET_STYLE_GO, 30, decor.WCSyncWidth), "done",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,6 @@ package decor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
_ = iota
|
|
||||||
UnitKiB
|
|
||||||
UnitKB
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CountersNoUnit is a wrapper around Counters with no unit param.
|
// CountersNoUnit is a wrapper around Counters with no unit param.
|
||||||
|
|
@ -17,54 +10,60 @@ func CountersNoUnit(pairFmt string, wcc ...WC) Decorator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountersKibiByte is a wrapper around Counters with predefined unit
|
// CountersKibiByte is a wrapper around Counters with predefined unit
|
||||||
// UnitKiB (bytes/1024).
|
// as SizeB1024(0).
|
||||||
func CountersKibiByte(pairFmt string, wcc ...WC) Decorator {
|
func CountersKibiByte(pairFmt string, wcc ...WC) Decorator {
|
||||||
return Counters(UnitKiB, pairFmt, wcc...)
|
return Counters(SizeB1024(0), pairFmt, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountersKiloByte is a wrapper around Counters with predefined unit
|
// CountersKiloByte is a wrapper around Counters with predefined unit
|
||||||
// UnitKB (bytes/1000).
|
// as SizeB1000(0).
|
||||||
func CountersKiloByte(pairFmt string, wcc ...WC) Decorator {
|
func CountersKiloByte(pairFmt string, wcc ...WC) Decorator {
|
||||||
return Counters(UnitKB, pairFmt, wcc...)
|
return Counters(SizeB1000(0), pairFmt, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counters decorator with dynamic unit measure adjustment.
|
// Counters decorator with dynamic unit measure adjustment.
|
||||||
//
|
//
|
||||||
// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
|
// `unit` one of [0|SizeB1024(0)|SizeB1000(0)]
|
||||||
//
|
//
|
||||||
// `pairFmt` printf compatible verbs for current and total pair
|
// `pairFmt` printf compatible verbs for current and total
|
||||||
//
|
//
|
||||||
// `wcc` optional WC config
|
// `wcc` optional WC config
|
||||||
//
|
//
|
||||||
// pairFmt example if unit=UnitKB:
|
// pairFmt example if unit=SizeB1000(0):
|
||||||
//
|
//
|
||||||
// pairFmt="%.1f / %.1f" output: "1.0MB / 12.0MB"
|
|
||||||
// pairFmt="% .1f / % .1f" output: "1.0 MB / 12.0 MB"
|
|
||||||
// pairFmt="%d / %d" output: "1MB / 12MB"
|
// pairFmt="%d / %d" output: "1MB / 12MB"
|
||||||
// pairFmt="% d / % d" output: "1 MB / 12 MB"
|
// pairFmt="% d / % d" output: "1 MB / 12 MB"
|
||||||
func Counters(unit int, pairFmt string, wcc ...WC) Decorator {
|
// pairFmt="%.1f / %.1f" output: "1.0MB / 12.0MB"
|
||||||
producer := func(unit int, pairFmt string) DecorFunc {
|
// pairFmt="% .1f / % .1f" output: "1.0 MB / 12.0 MB"
|
||||||
if pairFmt == "" {
|
// pairFmt="%f / %f" output: "1.000000MB / 12.000000MB"
|
||||||
pairFmt = "%d / %d"
|
// pairFmt="% f / % f" output: "1.000000 MB / 12.000000 MB"
|
||||||
} else if strings.Count(pairFmt, "%") != 2 {
|
func Counters(unit interface{}, pairFmt string, wcc ...WC) Decorator {
|
||||||
panic("expected pairFmt with exactly 2 verbs")
|
producer := func() DecorFunc {
|
||||||
}
|
switch unit.(type) {
|
||||||
switch unit {
|
case SizeB1024:
|
||||||
case UnitKiB:
|
if pairFmt == "" {
|
||||||
|
pairFmt = "% d / % d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(pairFmt, SizeB1024(s.Current), SizeB1024(s.Total))
|
return fmt.Sprintf(pairFmt, SizeB1024(s.Current), SizeB1024(s.Total))
|
||||||
}
|
}
|
||||||
case UnitKB:
|
case SizeB1000:
|
||||||
|
if pairFmt == "" {
|
||||||
|
pairFmt = "% d / % d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(pairFmt, SizeB1000(s.Current), SizeB1000(s.Total))
|
return fmt.Sprintf(pairFmt, SizeB1000(s.Current), SizeB1000(s.Total))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if pairFmt == "" {
|
||||||
|
pairFmt = "%d / %d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(pairFmt, s.Current, s.Total)
|
return fmt.Sprintf(pairFmt, s.Current, s.Total)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Any(producer(unit, pairFmt), wcc...)
|
return Any(producer(), wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TotalNoUnit is a wrapper around Total with no unit param.
|
// TotalNoUnit is a wrapper around Total with no unit param.
|
||||||
|
|
@ -73,55 +72,60 @@ func TotalNoUnit(format string, wcc ...WC) Decorator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TotalKibiByte is a wrapper around Total with predefined unit
|
// TotalKibiByte is a wrapper around Total with predefined unit
|
||||||
// UnitKiB (bytes/1024).
|
// as SizeB1024(0).
|
||||||
func TotalKibiByte(format string, wcc ...WC) Decorator {
|
func TotalKibiByte(format string, wcc ...WC) Decorator {
|
||||||
return Total(UnitKiB, format, wcc...)
|
return Total(SizeB1024(0), format, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TotalKiloByte is a wrapper around Total with predefined unit
|
// TotalKiloByte is a wrapper around Total with predefined unit
|
||||||
// UnitKB (bytes/1000).
|
// as SizeB1000(0).
|
||||||
func TotalKiloByte(format string, wcc ...WC) Decorator {
|
func TotalKiloByte(format string, wcc ...WC) Decorator {
|
||||||
return Total(UnitKB, format, wcc...)
|
return Total(SizeB1000(0), format, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Total decorator with dynamic unit measure adjustment.
|
// Total decorator with dynamic unit measure adjustment.
|
||||||
//
|
//
|
||||||
// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
|
// `unit` one of [0|SizeB1024(0)|SizeB1000(0)]
|
||||||
//
|
//
|
||||||
// `format` printf compatible verb for Total
|
// `format` printf compatible verb for Total
|
||||||
//
|
//
|
||||||
// `wcc` optional WC config
|
// `wcc` optional WC config
|
||||||
//
|
//
|
||||||
// format example if unit=UnitKiB:
|
// format example if unit=SizeB1024(0):
|
||||||
//
|
//
|
||||||
// format="%.1f" output: "12.0MiB"
|
|
||||||
// format="% .1f" output: "12.0 MiB"
|
|
||||||
// format="%d" output: "12MiB"
|
// format="%d" output: "12MiB"
|
||||||
// format="% d" output: "12 MiB"
|
// format="% d" output: "12 MiB"
|
||||||
func Total(unit int, format string, wcc ...WC) Decorator {
|
// format="%.1f" output: "12.0MiB"
|
||||||
producer := func(unit int, format string) DecorFunc {
|
// format="% .1f" output: "12.0 MiB"
|
||||||
if format == "" {
|
// format="%f" output: "12.000000MiB"
|
||||||
format = "%d"
|
// format="% f" output: "12.000000 MiB"
|
||||||
} else if strings.Count(format, "%") != 1 {
|
func Total(unit interface{}, format string, wcc ...WC) Decorator {
|
||||||
panic("expected format with exactly 1 verb")
|
producer := func() DecorFunc {
|
||||||
}
|
switch unit.(type) {
|
||||||
|
case SizeB1024:
|
||||||
switch unit {
|
if format == "" {
|
||||||
case UnitKiB:
|
format = "% d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, SizeB1024(s.Total))
|
return fmt.Sprintf(format, SizeB1024(s.Total))
|
||||||
}
|
}
|
||||||
case UnitKB:
|
case SizeB1000:
|
||||||
|
if format == "" {
|
||||||
|
format = "% d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, SizeB1000(s.Total))
|
return fmt.Sprintf(format, SizeB1000(s.Total))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if format == "" {
|
||||||
|
format = "%d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, s.Total)
|
return fmt.Sprintf(format, s.Total)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Any(producer(unit, format), wcc...)
|
return Any(producer(), wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentNoUnit is a wrapper around Current with no unit param.
|
// CurrentNoUnit is a wrapper around Current with no unit param.
|
||||||
|
|
@ -130,55 +134,60 @@ func CurrentNoUnit(format string, wcc ...WC) Decorator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentKibiByte is a wrapper around Current with predefined unit
|
// CurrentKibiByte is a wrapper around Current with predefined unit
|
||||||
// UnitKiB (bytes/1024).
|
// as SizeB1024(0).
|
||||||
func CurrentKibiByte(format string, wcc ...WC) Decorator {
|
func CurrentKibiByte(format string, wcc ...WC) Decorator {
|
||||||
return Current(UnitKiB, format, wcc...)
|
return Current(SizeB1024(0), format, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentKiloByte is a wrapper around Current with predefined unit
|
// CurrentKiloByte is a wrapper around Current with predefined unit
|
||||||
// UnitKB (bytes/1000).
|
// as SizeB1000(0).
|
||||||
func CurrentKiloByte(format string, wcc ...WC) Decorator {
|
func CurrentKiloByte(format string, wcc ...WC) Decorator {
|
||||||
return Current(UnitKB, format, wcc...)
|
return Current(SizeB1000(0), format, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current decorator with dynamic unit measure adjustment.
|
// Current decorator with dynamic unit measure adjustment.
|
||||||
//
|
//
|
||||||
// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
|
// `unit` one of [0|SizeB1024(0)|SizeB1000(0)]
|
||||||
//
|
//
|
||||||
// `format` printf compatible verb for Current
|
// `format` printf compatible verb for Current
|
||||||
//
|
//
|
||||||
// `wcc` optional WC config
|
// `wcc` optional WC config
|
||||||
//
|
//
|
||||||
// format example if unit=UnitKiB:
|
// format example if unit=SizeB1024(0):
|
||||||
//
|
//
|
||||||
// format="%.1f" output: "12.0MiB"
|
|
||||||
// format="% .1f" output: "12.0 MiB"
|
|
||||||
// format="%d" output: "12MiB"
|
// format="%d" output: "12MiB"
|
||||||
// format="% d" output: "12 MiB"
|
// format="% d" output: "12 MiB"
|
||||||
func Current(unit int, format string, wcc ...WC) Decorator {
|
// format="%.1f" output: "12.0MiB"
|
||||||
producer := func(unit int, format string) DecorFunc {
|
// format="% .1f" output: "12.0 MiB"
|
||||||
if format == "" {
|
// format="%f" output: "12.000000MiB"
|
||||||
format = "%d"
|
// format="% f" output: "12.000000 MiB"
|
||||||
} else if strings.Count(format, "%") != 1 {
|
func Current(unit interface{}, format string, wcc ...WC) Decorator {
|
||||||
panic("expected format with exactly 1 verb")
|
producer := func() DecorFunc {
|
||||||
}
|
switch unit.(type) {
|
||||||
|
case SizeB1024:
|
||||||
switch unit {
|
if format == "" {
|
||||||
case UnitKiB:
|
format = "% d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, SizeB1024(s.Current))
|
return fmt.Sprintf(format, SizeB1024(s.Current))
|
||||||
}
|
}
|
||||||
case UnitKB:
|
case SizeB1000:
|
||||||
|
if format == "" {
|
||||||
|
format = "% d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, SizeB1000(s.Current))
|
return fmt.Sprintf(format, SizeB1000(s.Current))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if format == "" {
|
||||||
|
format = "%d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, s.Current)
|
return fmt.Sprintf(format, s.Current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Any(producer(unit, format), wcc...)
|
return Any(producer(), wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InvertedCurrentNoUnit is a wrapper around InvertedCurrent with no unit param.
|
// InvertedCurrentNoUnit is a wrapper around InvertedCurrent with no unit param.
|
||||||
|
|
@ -187,53 +196,58 @@ func InvertedCurrentNoUnit(format string, wcc ...WC) Decorator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// InvertedCurrentKibiByte is a wrapper around InvertedCurrent with predefined unit
|
// InvertedCurrentKibiByte is a wrapper around InvertedCurrent with predefined unit
|
||||||
// UnitKiB (bytes/1024).
|
// as SizeB1024(0).
|
||||||
func InvertedCurrentKibiByte(format string, wcc ...WC) Decorator {
|
func InvertedCurrentKibiByte(format string, wcc ...WC) Decorator {
|
||||||
return InvertedCurrent(UnitKiB, format, wcc...)
|
return InvertedCurrent(SizeB1024(0), format, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InvertedCurrentKiloByte is a wrapper around InvertedCurrent with predefined unit
|
// InvertedCurrentKiloByte is a wrapper around InvertedCurrent with predefined unit
|
||||||
// UnitKB (bytes/1000).
|
// as SizeB1000(0).
|
||||||
func InvertedCurrentKiloByte(format string, wcc ...WC) Decorator {
|
func InvertedCurrentKiloByte(format string, wcc ...WC) Decorator {
|
||||||
return InvertedCurrent(UnitKB, format, wcc...)
|
return InvertedCurrent(SizeB1000(0), format, wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InvertedCurrent decorator with dynamic unit measure adjustment.
|
// InvertedCurrent decorator with dynamic unit measure adjustment.
|
||||||
//
|
//
|
||||||
// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
|
// `unit` one of [0|SizeB1024(0)|SizeB1000(0)]
|
||||||
//
|
//
|
||||||
// `format` printf compatible verb for InvertedCurrent
|
// `format` printf compatible verb for InvertedCurrent
|
||||||
//
|
//
|
||||||
// `wcc` optional WC config
|
// `wcc` optional WC config
|
||||||
//
|
//
|
||||||
// format example if unit=UnitKiB:
|
// format example if unit=SizeB1024(0):
|
||||||
//
|
//
|
||||||
// format="%.1f" output: "12.0MiB"
|
|
||||||
// format="% .1f" output: "12.0 MiB"
|
|
||||||
// format="%d" output: "12MiB"
|
// format="%d" output: "12MiB"
|
||||||
// format="% d" output: "12 MiB"
|
// format="% d" output: "12 MiB"
|
||||||
func InvertedCurrent(unit int, format string, wcc ...WC) Decorator {
|
// format="%.1f" output: "12.0MiB"
|
||||||
producer := func(unit int, format string) DecorFunc {
|
// format="% .1f" output: "12.0 MiB"
|
||||||
if format == "" {
|
// format="%f" output: "12.000000MiB"
|
||||||
format = "%d"
|
// format="% f" output: "12.000000 MiB"
|
||||||
} else if strings.Count(format, "%") != 1 {
|
func InvertedCurrent(unit interface{}, format string, wcc ...WC) Decorator {
|
||||||
panic("expected format with exactly 1 verb")
|
producer := func() DecorFunc {
|
||||||
}
|
switch unit.(type) {
|
||||||
|
case SizeB1024:
|
||||||
switch unit {
|
if format == "" {
|
||||||
case UnitKiB:
|
format = "% d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, SizeB1024(s.Total-s.Current))
|
return fmt.Sprintf(format, SizeB1024(s.Total-s.Current))
|
||||||
}
|
}
|
||||||
case UnitKB:
|
case SizeB1000:
|
||||||
|
if format == "" {
|
||||||
|
format = "% d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, SizeB1000(s.Total-s.Current))
|
return fmt.Sprintf(format, SizeB1000(s.Total-s.Current))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if format == "" {
|
||||||
|
format = "%d"
|
||||||
|
}
|
||||||
return func(s Statistics) string {
|
return func(s Statistics) string {
|
||||||
return fmt.Sprintf(format, s.Total-s.Current)
|
return fmt.Sprintf(format, s.Total-s.Current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Any(producer(unit, format), wcc...)
|
return Any(producer(), wcc...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,8 +199,7 @@ func chooseTimeProducer(style TimeStyle) func(time.Duration) string {
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return func(remaining time.Duration) string {
|
return func(remaining time.Duration) string {
|
||||||
// strip off nanoseconds
|
return remaining.Truncate(time.Second).String()
|
||||||
return ((remaining / time.Second) * time.Second).String()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ type onAbortWrapper struct {
|
||||||
|
|
||||||
func (d *onAbortWrapper) Decor(s Statistics) string {
|
func (d *onAbortWrapper) Decor(s Statistics) string {
|
||||||
if s.Aborted {
|
if s.Aborted {
|
||||||
wc := d.GetConf()
|
return d.GetConf().FormatMsg(d.msg)
|
||||||
return wc.FormatMsg(d.msg)
|
|
||||||
}
|
}
|
||||||
return d.Decorator.Decor(s)
|
return d.Decorator.Decor(s)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,7 @@ type onCompleteWrapper struct {
|
||||||
|
|
||||||
func (d *onCompleteWrapper) Decor(s Statistics) string {
|
func (d *onCompleteWrapper) Decor(s Statistics) string {
|
||||||
if s.Completed {
|
if s.Completed {
|
||||||
wc := d.GetConf()
|
return d.GetConf().FormatMsg(d.msg)
|
||||||
return wc.FormatMsg(d.msg)
|
|
||||||
}
|
}
|
||||||
return d.Decorator.Decor(s)
|
return d.Decorator.Decor(s)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,24 +7,25 @@ import (
|
||||||
"github.com/vbauerster/mpb/v8/internal"
|
"github.com/vbauerster/mpb/v8/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ fmt.Formatter = percentageType(0)
|
||||||
|
|
||||||
type percentageType float64
|
type percentageType float64
|
||||||
|
|
||||||
func (s percentageType) Format(st fmt.State, verb rune) {
|
func (s percentageType) Format(st fmt.State, verb rune) {
|
||||||
var prec int
|
prec := -1
|
||||||
switch verb {
|
switch verb {
|
||||||
case 'd':
|
case 'f', 'e', 'E':
|
||||||
case 's':
|
prec = 6 // default prec of fmt.Printf("%f|%e|%E")
|
||||||
prec = -1
|
fallthrough
|
||||||
default:
|
case 'b', 'g', 'G', 'x', 'X':
|
||||||
if p, ok := st.Precision(); ok {
|
if p, ok := st.Precision(); ok {
|
||||||
prec = p
|
prec = p
|
||||||
} else {
|
|
||||||
prec = 6
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
verb, prec = 'f', 0
|
||||||
}
|
}
|
||||||
|
|
||||||
p := bytesPool.Get().(*[]byte)
|
b := strconv.AppendFloat(make([]byte, 0, 16), float64(s), byte(verb), prec, 64)
|
||||||
b := strconv.AppendFloat(*p, float64(s), 'f', prec, 64)
|
|
||||||
if st.Flag(' ') {
|
if st.Flag(' ') {
|
||||||
b = append(b, ' ', '%')
|
b = append(b, ' ', '%')
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -34,7 +35,6 @@ func (s percentageType) Format(st fmt.State, verb rune) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
bytesPool.Put(p)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Percentage returns percentage decorator. It's a wrapper of NewPercentage.
|
// Percentage returns percentage decorator. It's a wrapper of NewPercentage.
|
||||||
|
|
@ -44,12 +44,18 @@ func Percentage(wcc ...WC) Decorator {
|
||||||
|
|
||||||
// NewPercentage percentage decorator with custom format string.
|
// NewPercentage percentage decorator with custom format string.
|
||||||
//
|
//
|
||||||
|
// `format` printf compatible verb
|
||||||
|
//
|
||||||
|
// `wcc` optional WC config
|
||||||
|
//
|
||||||
// format examples:
|
// format examples:
|
||||||
//
|
//
|
||||||
// format="%.1f" output: "1.0%"
|
|
||||||
// format="% .1f" output: "1.0 %"
|
|
||||||
// format="%d" output: "1%"
|
// format="%d" output: "1%"
|
||||||
// format="% d" output: "1 %"
|
// format="% d" output: "1 %"
|
||||||
|
// format="%.1f" output: "1.0%"
|
||||||
|
// format="% .1f" output: "1.0 %"
|
||||||
|
// format="%f" output: "1.000000%"
|
||||||
|
// format="% f" output: "1.000000 %"
|
||||||
func NewPercentage(format string, wcc ...WC) Decorator {
|
func NewPercentage(format string, wcc ...WC) Decorator {
|
||||||
if format == "" {
|
if format == "" {
|
||||||
format = "% d"
|
format = "% d"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
package decor
|
|
||||||
|
|
||||||
import "sync"
|
|
||||||
|
|
||||||
var bytesPool = sync.Pool{
|
|
||||||
New: func() interface{} {
|
|
||||||
b := make([]byte, 0, 32)
|
|
||||||
return &b
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -8,6 +8,13 @@ import (
|
||||||
//go:generate stringer -type=SizeB1024 -trimprefix=_i
|
//go:generate stringer -type=SizeB1024 -trimprefix=_i
|
||||||
//go:generate stringer -type=SizeB1000 -trimprefix=_
|
//go:generate stringer -type=SizeB1000 -trimprefix=_
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ fmt.Formatter = SizeB1024(0)
|
||||||
|
_ fmt.Stringer = SizeB1024(0)
|
||||||
|
_ fmt.Formatter = SizeB1000(0)
|
||||||
|
_ fmt.Stringer = SizeB1000(0)
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ib SizeB1024 = iota + 1
|
_ib SizeB1024 = iota + 1
|
||||||
_iKiB SizeB1024 = 1 << (iota * 10)
|
_iKiB SizeB1024 = 1 << (iota * 10)
|
||||||
|
|
@ -22,17 +29,17 @@ const (
|
||||||
type SizeB1024 int64
|
type SizeB1024 int64
|
||||||
|
|
||||||
func (self SizeB1024) Format(st fmt.State, verb rune) {
|
func (self SizeB1024) Format(st fmt.State, verb rune) {
|
||||||
var prec int
|
prec := -1
|
||||||
switch verb {
|
switch verb {
|
||||||
case 'd':
|
case 'f', 'e', 'E':
|
||||||
case 's':
|
prec = 6 // default prec of fmt.Printf("%f|%e|%E")
|
||||||
prec = -1
|
fallthrough
|
||||||
default:
|
case 'b', 'g', 'G', 'x', 'X':
|
||||||
if p, ok := st.Precision(); ok {
|
if p, ok := st.Precision(); ok {
|
||||||
prec = p
|
prec = p
|
||||||
} else {
|
|
||||||
prec = 6
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
verb, prec = 'f', 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var unit SizeB1024
|
var unit SizeB1024
|
||||||
|
|
@ -49,8 +56,7 @@ func (self SizeB1024) Format(st fmt.State, verb rune) {
|
||||||
unit = _iTiB
|
unit = _iTiB
|
||||||
}
|
}
|
||||||
|
|
||||||
p := bytesPool.Get().(*[]byte)
|
b := strconv.AppendFloat(make([]byte, 0, 24), float64(self)/float64(unit), byte(verb), prec, 64)
|
||||||
b := strconv.AppendFloat(*p, float64(self)/float64(unit), 'f', prec, 64)
|
|
||||||
if st.Flag(' ') {
|
if st.Flag(' ') {
|
||||||
b = append(b, ' ')
|
b = append(b, ' ')
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +65,6 @@ func (self SizeB1024) Format(st fmt.State, verb rune) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
bytesPool.Put(p)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -76,17 +81,17 @@ const (
|
||||||
type SizeB1000 int64
|
type SizeB1000 int64
|
||||||
|
|
||||||
func (self SizeB1000) Format(st fmt.State, verb rune) {
|
func (self SizeB1000) Format(st fmt.State, verb rune) {
|
||||||
var prec int
|
prec := -1
|
||||||
switch verb {
|
switch verb {
|
||||||
case 'd':
|
case 'f', 'e', 'E':
|
||||||
case 's':
|
prec = 6 // default prec of fmt.Printf("%f|%e|%E")
|
||||||
prec = -1
|
fallthrough
|
||||||
default:
|
case 'b', 'g', 'G', 'x', 'X':
|
||||||
if p, ok := st.Precision(); ok {
|
if p, ok := st.Precision(); ok {
|
||||||
prec = p
|
prec = p
|
||||||
} else {
|
|
||||||
prec = 6
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
verb, prec = 'f', 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var unit SizeB1000
|
var unit SizeB1000
|
||||||
|
|
@ -103,8 +108,7 @@ func (self SizeB1000) Format(st fmt.State, verb rune) {
|
||||||
unit = _TB
|
unit = _TB
|
||||||
}
|
}
|
||||||
|
|
||||||
p := bytesPool.Get().(*[]byte)
|
b := strconv.AppendFloat(make([]byte, 0, 24), float64(self)/float64(unit), byte(verb), prec, 64)
|
||||||
b := strconv.AppendFloat(*p, float64(self)/float64(unit), 'f', prec, 64)
|
|
||||||
if st.Flag(' ') {
|
if st.Flag(' ') {
|
||||||
b = append(b, ' ')
|
b = append(b, ' ')
|
||||||
}
|
}
|
||||||
|
|
@ -113,5 +117,4 @@ func (self SizeB1000) Format(st fmt.State, verb rune) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
bytesPool.Put(p)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func (self speedFormatter) Format(st fmt.State, verb rune) {
|
||||||
// EwmaSpeed exponential-weighted-moving-average based speed decorator.
|
// EwmaSpeed exponential-weighted-moving-average based speed decorator.
|
||||||
// For this decorator to work correctly you have to measure each iteration's
|
// For this decorator to work correctly you have to measure each iteration's
|
||||||
// duration and pass it to one of the (*Bar).EwmaIncr... family methods.
|
// duration and pass it to one of the (*Bar).EwmaIncr... family methods.
|
||||||
func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
|
func EwmaSpeed(unit interface{}, format string, age float64, wcc ...WC) Decorator {
|
||||||
var average ewma.MovingAverage
|
var average ewma.MovingAverage
|
||||||
if age == 0 {
|
if age == 0 {
|
||||||
average = ewma.NewMovingAverage()
|
average = ewma.NewMovingAverage()
|
||||||
|
|
@ -52,7 +52,7 @@ func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
|
||||||
// MovingAverageSpeed decorator relies on MovingAverage implementation
|
// MovingAverageSpeed decorator relies on MovingAverage implementation
|
||||||
// to calculate its average.
|
// to calculate its average.
|
||||||
//
|
//
|
||||||
// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
|
// `unit` one of [0|SizeB1024(0)|SizeB1000(0)]
|
||||||
//
|
//
|
||||||
// `format` printf compatible verb for value, like "%f" or "%d"
|
// `format` printf compatible verb for value, like "%f" or "%d"
|
||||||
//
|
//
|
||||||
|
|
@ -62,14 +62,11 @@ func EwmaSpeed(unit int, format string, age float64, wcc ...WC) Decorator {
|
||||||
//
|
//
|
||||||
// format examples:
|
// format examples:
|
||||||
//
|
//
|
||||||
// unit=UnitKiB, format="%.1f" output: "1.0MiB/s"
|
// unit=SizeB1024(0), format="%.1f" output: "1.0MiB/s"
|
||||||
// unit=UnitKiB, format="% .1f" output: "1.0 MiB/s"
|
// unit=SizeB1024(0), format="% .1f" output: "1.0 MiB/s"
|
||||||
// unit=UnitKB, format="%.1f" output: "1.0MB/s"
|
// unit=SizeB1000(0), format="%.1f" output: "1.0MB/s"
|
||||||
// unit=UnitKB, format="% .1f" output: "1.0 MB/s"
|
// unit=SizeB1000(0), format="% .1f" output: "1.0 MB/s"
|
||||||
func MovingAverageSpeed(unit int, format string, average ewma.MovingAverage, wcc ...WC) Decorator {
|
func MovingAverageSpeed(unit interface{}, format string, average ewma.MovingAverage, wcc ...WC) Decorator {
|
||||||
if format == "" {
|
|
||||||
format = "%.0f"
|
|
||||||
}
|
|
||||||
d := &movingAverageSpeed{
|
d := &movingAverageSpeed{
|
||||||
WC: initWC(wcc...),
|
WC: initWC(wcc...),
|
||||||
average: average,
|
average: average,
|
||||||
|
|
@ -106,14 +103,14 @@ func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) {
|
||||||
|
|
||||||
// AverageSpeed decorator with dynamic unit measure adjustment. It's
|
// AverageSpeed decorator with dynamic unit measure adjustment. It's
|
||||||
// a wrapper of NewAverageSpeed.
|
// a wrapper of NewAverageSpeed.
|
||||||
func AverageSpeed(unit int, format string, wcc ...WC) Decorator {
|
func AverageSpeed(unit interface{}, format string, wcc ...WC) Decorator {
|
||||||
return NewAverageSpeed(unit, format, time.Now(), wcc...)
|
return NewAverageSpeed(unit, format, time.Now(), wcc...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAverageSpeed decorator with dynamic unit measure adjustment and
|
// NewAverageSpeed decorator with dynamic unit measure adjustment and
|
||||||
// user provided start time.
|
// user provided start time.
|
||||||
//
|
//
|
||||||
// `unit` one of [0|UnitKiB|UnitKB] zero for no unit
|
// `unit` one of [0|SizeB1024(0)|SizeB1000(0)]
|
||||||
//
|
//
|
||||||
// `format` printf compatible verb for value, like "%f" or "%d"
|
// `format` printf compatible verb for value, like "%f" or "%d"
|
||||||
//
|
//
|
||||||
|
|
@ -123,14 +120,11 @@ func AverageSpeed(unit int, format string, wcc ...WC) Decorator {
|
||||||
//
|
//
|
||||||
// format examples:
|
// format examples:
|
||||||
//
|
//
|
||||||
// unit=UnitKiB, format="%.1f" output: "1.0MiB/s"
|
// unit=SizeB1024(0), format="%.1f" output: "1.0MiB/s"
|
||||||
// unit=UnitKiB, format="% .1f" output: "1.0 MiB/s"
|
// unit=SizeB1024(0), format="% .1f" output: "1.0 MiB/s"
|
||||||
// unit=UnitKB, format="%.1f" output: "1.0MB/s"
|
// unit=SizeB1000(0), format="%.1f" output: "1.0MB/s"
|
||||||
// unit=UnitKB, format="% .1f" output: "1.0 MB/s"
|
// unit=SizeB1000(0), format="% .1f" output: "1.0 MB/s"
|
||||||
func NewAverageSpeed(unit int, format string, startTime time.Time, wcc ...WC) Decorator {
|
func NewAverageSpeed(unit interface{}, format string, startTime time.Time, wcc ...WC) Decorator {
|
||||||
if format == "" {
|
|
||||||
format = "%.0f"
|
|
||||||
}
|
|
||||||
d := &averageSpeed{
|
d := &averageSpeed{
|
||||||
WC: initWC(wcc...),
|
WC: initWC(wcc...),
|
||||||
startTime: startTime,
|
startTime: startTime,
|
||||||
|
|
@ -151,7 +145,6 @@ func (d *averageSpeed) Decor(s Statistics) string {
|
||||||
speed := float64(s.Current) / float64(time.Since(d.startTime))
|
speed := float64(s.Current) / float64(time.Since(d.startTime))
|
||||||
d.msg = d.producer(speed * 1e9)
|
d.msg = d.producer(speed * 1e9)
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.FormatMsg(d.msg)
|
return d.FormatMsg(d.msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,17 +152,26 @@ func (d *averageSpeed) AverageAdjust(startTime time.Time) {
|
||||||
d.startTime = startTime
|
d.startTime = startTime
|
||||||
}
|
}
|
||||||
|
|
||||||
func chooseSpeedProducer(unit int, format string) func(float64) string {
|
func chooseSpeedProducer(unit interface{}, format string) func(float64) string {
|
||||||
switch unit {
|
switch unit.(type) {
|
||||||
case UnitKiB:
|
case SizeB1024:
|
||||||
|
if format == "" {
|
||||||
|
format = "% d"
|
||||||
|
}
|
||||||
return func(speed float64) string {
|
return func(speed float64) string {
|
||||||
return fmt.Sprintf(format, FmtAsSpeed(SizeB1024(math.Round(speed))))
|
return fmt.Sprintf(format, FmtAsSpeed(SizeB1024(math.Round(speed))))
|
||||||
}
|
}
|
||||||
case UnitKB:
|
case SizeB1000:
|
||||||
|
if format == "" {
|
||||||
|
format = "% d"
|
||||||
|
}
|
||||||
return func(speed float64) string {
|
return func(speed float64) string {
|
||||||
return fmt.Sprintf(format, FmtAsSpeed(SizeB1000(math.Round(speed))))
|
return fmt.Sprintf(format, FmtAsSpeed(SizeB1000(math.Round(speed))))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if format == "" {
|
||||||
|
format = "%f"
|
||||||
|
}
|
||||||
return func(speed float64) string {
|
return func(speed float64) string {
|
||||||
return fmt.Sprintf(format, speed)
|
return fmt.Sprintf(format, speed)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ func (m heapManager) run() {
|
||||||
var sync bool
|
var sync bool
|
||||||
|
|
||||||
for req := range m {
|
for req := range m {
|
||||||
|
next:
|
||||||
switch req.cmd {
|
switch req.cmd {
|
||||||
case h_push:
|
case h_push:
|
||||||
data := req.data.(pushData)
|
data := req.data.(pushData)
|
||||||
|
|
@ -78,7 +79,8 @@ func (m heapManager) run() {
|
||||||
select {
|
select {
|
||||||
case data.iter <- b:
|
case data.iter <- b:
|
||||||
case <-data.drop:
|
case <-data.drop:
|
||||||
break
|
close(data.iter)
|
||||||
|
break next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(data.iter)
|
close(data.iter)
|
||||||
|
|
@ -88,7 +90,8 @@ func (m heapManager) run() {
|
||||||
select {
|
select {
|
||||||
case data.iter <- heap.Pop(&bHeap).(*Bar):
|
case data.iter <- heap.Pop(&bHeap).(*Bar):
|
||||||
case <-data.drop:
|
case <-data.drop:
|
||||||
break
|
close(data.iter)
|
||||||
|
break next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(data.iter)
|
close(data.iter)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DoneError represents an error when `*mpb.Progress` is done but its functionality is requested.
|
// DoneError represents an error when `*mpb.Progress` is done but its functionality is requested.
|
||||||
var DoneError = fmt.Errorf("%T instance can't be reused after it's done!", (*Progress)(nil))
|
var DoneError = fmt.Errorf("%T instance can't be reused after it's done", (*Progress)(nil))
|
||||||
|
|
||||||
// Progress represents a container that renders one or more progress bars.
|
// Progress represents a container that renders one or more progress bars.
|
||||||
type Progress struct {
|
type Progress struct {
|
||||||
|
|
@ -351,7 +351,7 @@ func (s *pState) render(cw *cwriter.Writer) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *pState) flush(cw *cwriter.Writer, height int) error {
|
func (s *pState) flush(cw *cwriter.Writer, height int) error {
|
||||||
wg := new(sync.WaitGroup)
|
var wg sync.WaitGroup
|
||||||
defer wg.Wait() // waiting for all s.hm.push to complete
|
defer wg.Wait() // waiting for all s.hm.push to complete
|
||||||
|
|
||||||
var popCount int
|
var popCount int
|
||||||
|
|
|
||||||
|
|
@ -878,7 +878,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.3.0
|
# github.com/vbauerster/mpb/v8 v8.4.0
|
||||||
## 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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue