Codebase list golang-github-vbauerster-mpb / 57833c1
TimeStyle Vladimir Bauer 7 years ago
3 changed file(s) with 13 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
3030 DSyncSpaceR = DSyncWidth | DextraSpace | DidentRight
3131 )
3232
33 // TimeStyle enum.
34 type TimeStyle int
35
36 // TimeStyle kinds.
3337 const (
34 ET_STYLE_GO = iota
38 ET_STYLE_GO TimeStyle = iota
3539 ET_STYLE_HHMMSS
3640 ET_STYLE_HHMM
3741 ET_STYLE_MMSS
5458 }
5559
5660 // Syncable interface.
57 // All decorators implement this interface implicitly. Its Syncable
61 // All decorators implement this interface implicitly. Its Syncable
5862 // method exposes width sync channel, if sync is enabled.
5963 type Syncable interface {
6064 Syncable() (bool, chan int)
99 // `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
1010 //
1111 // `wcc` optional WC config
12 func Elapsed(style int, wcc ...WC) Decorator {
12 func Elapsed(style TimeStyle, wcc ...WC) Decorator {
1313 var wc WC
1414 for _, widthConf := range wcc {
1515 wc = widthConf
2525
2626 type elapsedDecorator struct {
2727 WC
28 style int
28 style TimeStyle
2929 startTime time.Time
3030 msg string
3131 completeMsg *string
1616 // `age` is the previous N samples to average over.
1717 //
1818 // `wcc` optional WC config
19 func EwmaETA(style int, age float64, wcc ...WC) Decorator {
19 func EwmaETA(style TimeStyle, age float64, wcc ...WC) Decorator {
2020 return MovingAverageETA(style, ewma.NewMovingAverage(age), NopNormalizer(), wcc...)
2121 }
2222
2929 // `normalizer` available implementations are [NopNormalizer|FixedIntervalTimeNormalizer|MaxTolerateTimeNormalizer]
3030 //
3131 // `wcc` optional WC config
32 func MovingAverageETA(style int, average MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
32 func MovingAverageETA(style TimeStyle, average MovingAverage, normalizer TimeNormalizer, wcc ...WC) Decorator {
3333 var wc WC
3434 for _, widthConf := range wcc {
3535 wc = widthConf
4646
4747 type movingAverageETA struct {
4848 WC
49 style int
49 style TimeStyle
5050 average ewma.MovingAverage
5151 completeMsg *string
5252 normalizer TimeNormalizer
103103 // `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS]
104104 //
105105 // `wcc` optional WC config
106 func AverageETA(style int, wcc ...WC) Decorator {
106 func AverageETA(style TimeStyle, wcc ...WC) Decorator {
107107 var wc WC
108108 for _, widthConf := range wcc {
109109 wc = widthConf
119119
120120 type averageETA struct {
121121 WC
122 style int
122 style TimeStyle
123123 startTime time.Time
124124 completeMsg *string
125125 }