@@ -41,6 +41,7 @@ func (w *MultipleWritersWithSource) AddWriters(writers ...WriterWithSource) erro
4141 }
4242 return nil
4343}
44+
4445func (w * MultipleWritersWithSource ) Write (p []byte ) (n int , err error ) {
4546 writers , err := w .GetWriters ()
4647 if err != nil {
@@ -133,12 +134,24 @@ func NewDiodeWriterForSlowWriterWithoutClosing(slowWriter WriterWithSource, ring
133134 return newDiodeWriterForSlowWriter (false , slowWriter , ringBufferSize , pollInterval , droppedMessagesLogger )
134135}
135136
137+ type nonCloseableWriter struct {
138+ io.Writer
139+ }
140+
141+ func (ncw nonCloseableWriter ) Close () error {
142+ return nil
143+ }
144+
136145func newDiodeWriterForSlowWriter (closeWriterOnClose bool , slowWriter WriterWithSource , ringBufferSize int , pollInterval time.Duration , droppedMessagesLogger Loggers ) WriterWithSource {
137146 closerStore := parallelisation .NewCloserStore (false )
138147 if closeWriterOnClose {
139148 closerStore .RegisterCloser (slowWriter )
140149 }
141- d := diode .NewWriter (slowWriter , ringBufferSize , pollInterval , func (missed int ) {
150+
151+ // We pass a wrapper that "overrides" the close method to do nothing,
152+ // this is because we control the writer's close behaviour through the `closeWriterOnClose` check
153+ ncw := nonCloseableWriter {slowWriter }
154+ d := diode .NewWriter (ncw , ringBufferSize , pollInterval , func (missed int ) {
142155 if droppedMessagesLogger != nil {
143156 droppedMessagesLogger .LogError (fmt .Sprintf ("Logger dropped %d messages" , missed ))
144157 }
0 commit comments