mattbaird/elastigo

BulkIndexer reads whole buffer before writing to ErrorChannel

gburgett opened this issue · 0 comments

Currently, in startHttpSender(), if an error occurs then the buffer which was sent is queued to the ErrorChannel. Unfortunately, with the default Send implementation, this buffer has been fully read. My application code is reading from the ErrorChannel to perform more complex error handling, and I need to read that buffer.

I'm working around it right now with this code where I instantiate the indexer:

indexer.Sender = func(buf *bytes.Buffer) error {
        //clone the buffer before we send
        return indexer.Send(bytes.NewBuffer(buf.Bytes()))
    }

If I have some time later I may submit a pull request, it should be a simple change.