diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-03-09 15:51:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 15:51:57 -0500 |
commit | d3e6c2a7abe2d3389db01dac81a4de792a4c180b (patch) | |
tree | d821c0b2214e0b1e9b54ddd178db50f53b167651 /vendor/github.com/vbauerster/mpb/v6/proxyreader.go | |
parent | f960ac7ec3e226a38bed7cf6a6f9e8775b13b7f1 (diff) | |
parent | 30bf065c3ffc16214e820e8568387e4561b5f83a (diff) | |
download | podman-d3e6c2a7abe2d3389db01dac81a4de792a4c180b.tar.gz podman-d3e6c2a7abe2d3389db01dac81a4de792a4c180b.tar.bz2 podman-d3e6c2a7abe2d3389db01dac81a4de792a4c180b.zip |
Merge pull request #13471 from Luap99/bump-mpbv7
Use github.com/vbauerster/mpb/v7 in pkg/machine
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v6/proxyreader.go')
-rw-r--r-- | vendor/github.com/vbauerster/mpb/v6/proxyreader.go | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v6/proxyreader.go b/vendor/github.com/vbauerster/mpb/v6/proxyreader.go deleted file mode 100644 index 316f438d7..000000000 --- a/vendor/github.com/vbauerster/mpb/v6/proxyreader.go +++ /dev/null @@ -1,90 +0,0 @@ -package mpb - -import ( - "io" - "io/ioutil" - "time" -) - -type proxyReader struct { - io.ReadCloser - bar *Bar -} - -func (x *proxyReader) Read(p []byte) (int, error) { - n, err := x.ReadCloser.Read(p) - x.bar.IncrBy(n) - if err == io.EOF { - go x.bar.SetTotal(0, true) - } - return n, err -} - -type proxyWriterTo struct { - io.ReadCloser // *proxyReader - wt io.WriterTo - bar *Bar -} - -func (x *proxyWriterTo) WriteTo(w io.Writer) (int64, error) { - n, err := x.wt.WriteTo(w) - x.bar.IncrInt64(n) - if err == io.EOF { - go x.bar.SetTotal(0, true) - } - return n, err -} - -type ewmaProxyReader struct { - io.ReadCloser // *proxyReader - bar *Bar - iT time.Time -} - -func (x *ewmaProxyReader) Read(p []byte) (int, error) { - n, err := x.ReadCloser.Read(p) - if n > 0 { - x.bar.DecoratorEwmaUpdate(time.Since(x.iT)) - x.iT = time.Now() - } - return n, err -} - -type ewmaProxyWriterTo struct { - io.ReadCloser // *ewmaProxyReader - wt io.WriterTo // *proxyWriterTo - bar *Bar - iT time.Time -} - -func (x *ewmaProxyWriterTo) WriteTo(w io.Writer) (int64, error) { - n, err := x.wt.WriteTo(w) - if n > 0 { - x.bar.DecoratorEwmaUpdate(time.Since(x.iT)) - x.iT = time.Now() - } - return n, err -} - -func newProxyReader(r io.Reader, bar *Bar) io.ReadCloser { - rc := toReadCloser(r) - rc = &proxyReader{rc, bar} - - if wt, isWriterTo := r.(io.WriterTo); bar.hasEwmaDecorators { - now := time.Now() - rc = &ewmaProxyReader{rc, bar, now} - if isWriterTo { - rc = &ewmaProxyWriterTo{rc, wt, bar, now} - } - } else if isWriterTo { - rc = &proxyWriterTo{rc, wt, bar} - } - return rc -} - -func toReadCloser(r io.Reader) io.ReadCloser { - if rc, ok := r.(io.ReadCloser); ok { - return rc - } - return ioutil.NopCloser(r) -} |