mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
pkg/ioutils: deprecate NopFlusher
Apart from being used internally for NewWriteFlusher, it's only used
in a single location outside of this package. Copy the implementation
where it's used, and mark it deprecated.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 818a180fce)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -339,8 +339,12 @@ type flusher interface {
|
||||
Flush()
|
||||
}
|
||||
|
||||
type nopFlusher struct{}
|
||||
|
||||
func (f *nopFlusher) Flush() {}
|
||||
|
||||
func wrapOutputBufferedUntilRequestRead(rc io.ReadCloser, out io.Writer) (io.ReadCloser, io.Writer) {
|
||||
var fl flusher = &ioutils.NopFlusher{}
|
||||
var fl flusher = &nopFlusher{}
|
||||
if f, ok := out.(flusher); ok {
|
||||
fl = f
|
||||
}
|
||||
|
||||
@@ -80,13 +80,19 @@ func (wf *WriteFlusher) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// nopFlusher represents a type which flush operation is nop.
|
||||
type nopFlusher struct{}
|
||||
|
||||
// Flush is a nop operation.
|
||||
func (f *nopFlusher) Flush() {}
|
||||
|
||||
// NewWriteFlusher returns a new WriteFlusher.
|
||||
func NewWriteFlusher(w io.Writer) *WriteFlusher {
|
||||
var fl flusher
|
||||
if f, ok := w.(flusher); ok {
|
||||
fl = f
|
||||
} else {
|
||||
fl = &NopFlusher{}
|
||||
fl = &nopFlusher{}
|
||||
}
|
||||
return &WriteFlusher{w: w, flusher: fl, closed: make(chan struct{}), flushed: make(chan struct{})}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,9 @@ func NopWriteCloser(w io.Writer) io.WriteCloser {
|
||||
}
|
||||
|
||||
// NopFlusher represents a type which flush operation is nop.
|
||||
type NopFlusher struct{}
|
||||
|
||||
// Flush is a nop operation.
|
||||
func (f *NopFlusher) Flush() {}
|
||||
//
|
||||
// Deprecated: NopFlusher is only used internally and will be removed in the next release.
|
||||
type NopFlusher = nopFlusher
|
||||
|
||||
type writeCloserWrapper struct {
|
||||
io.Writer
|
||||
|
||||
Reference in New Issue
Block a user