go-buffer icon indicating copy to clipboard operation
go-buffer copied to clipboard

Handle flush errors by putting values back in the buffer

Open maxwellhertz opened this issue 4 years ago • 0 comments

Prerequisites

  • [✔️] I searched to see if the issue already exists.

Description

I looked into the source code and found that values would be discarded if any error occurred during a flush.

// flush performs a flush asynchronuously.
func (b *Buffer) flush() {
	values := b.values
	b.values = nil
        // ...
	go func() {
		b.doFlush(values)
		b.pendingFlushes.Done()
	}()
}

func (b *Buffer) doFlush(values []interface{}) {
       // ...
	err := b.handleFlush(ctx, values)
        // ...
	if err != nil {
		b.handleError(err)
	}
}

Shouldn't it put all the values back in the buffer if it can't flush them successfully?

maxwellhertz avatar Dec 28 '20 13:12 maxwellhertz