Codebase list golang-github-vbauerster-mpb / e5ca799
refactor newProxyReader Make it bar's method. Vladimir Bauer 4 years ago
2 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
105105 if r == nil {
106106 panic("expected non nil io.Reader")
107107 }
108 return newProxyReader(r, b)
108 return b.newProxyReader(r)
109109 }
110110
111111 // ID returs id of the bar.
6363 return n, err
6464 }
6565
66 func newProxyReader(r io.Reader, bar *Bar) io.ReadCloser {
66 func (bar *Bar) newProxyReader(r io.Reader) io.ReadCloser {
6767 rc := toReadCloser(r)
68 rc = &proxyReader{rc, bar}
69
70 if wt, isWriterTo := r.(io.WriterTo); bar.hasEwmaDecorators {
71 rc = &ewmaProxyReader{rc, bar}
68 wt, isWriterTo := r.(io.WriterTo)
69 if bar.hasEwmaDecorators {
7270 if isWriterTo {
7371 rc = &ewmaProxyWriterTo{rc, wt, bar}
72 } else {
73 rc = &ewmaProxyReader{rc, bar}
7474 }
7575 } else if isWriterTo {
7676 rc = &proxyWriterTo{rc, wt, bar}
77 } else {
78 rc = &proxyReader{rc, bar}
7779 }
7880 return rc
7981 }