Codebase list golang-github-vbauerster-mpb / 11ef6c0
refactoring proxyreader Vladimir Bauer 6 years ago
2 changed file(s) with 11 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1010 iT time.Time
1111 }
1212
13 func (prox *proxyReader) Read(p []byte) (n int, err error) {
14 n, err = prox.ReadCloser.Read(p)
13 func (prox *proxyReader) Read(p []byte) (int, error) {
14 n, err := prox.ReadCloser.Read(p)
1515 if n > 0 {
16 prox.bar.IncrBy(n, time.Since(prox.iT))
16 prox.bar.IncrBy(n)
17 prox.bar.DecoratorEwmaUpdate(time.Since(prox.iT))
1718 prox.iT = time.Now()
1819 }
1920 if err == io.EOF {
2021 go prox.bar.SetTotal(0, true)
2122 }
22 return
23 return n, err
2324 }
2425
2526 type proxyWriterTo struct {
2728 wt io.WriterTo
2829 }
2930
30 func (prox *proxyWriterTo) WriteTo(w io.Writer) (n int64, err error) {
31 n, err = prox.wt.WriteTo(w)
31 func (prox *proxyWriterTo) WriteTo(w io.Writer) (int64, error) {
32 n, err := prox.wt.WriteTo(w)
3233 if n > 0 {
33 prox.bar.IncrInt64(n, time.Since(prox.iT))
34 prox.bar.IncrInt64(n)
35 prox.bar.DecoratorEwmaUpdate(time.Since(prox.iT))
3436 prox.iT = time.Now()
3537 }
3638 if err == io.EOF {
3739 go prox.bar.SetTotal(0, true)
3840 }
39 return
41 return n, err
4042 }
66 "strings"
77 "testing"
88
9 "github.com/vbauerster/mpb/v4"
9 "github.com/vbauerster/mpb/v5"
1010 )
1111
1212 const content = `Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do