writeBody writes the item body to the buffer.
(item *BulkIndexerItem)
| 648 | |
| 649 | // writeBody writes the item body to the buffer. |
| 650 | func (w *worker) writeBody(item *BulkIndexerItem) error { |
| 651 | if item.Body != nil { |
| 652 | if _, err := w.buf.ReadFrom(item.Body); err != nil { |
| 653 | if w.bi.config.OnError != nil { |
| 654 | w.bi.config.OnError(context.Background(), err) |
| 655 | } |
| 656 | return err |
| 657 | } |
| 658 | if _, err := item.Body.Seek(0, io.SeekStart); err != nil { |
| 659 | if w.bi.config.OnError != nil { |
| 660 | w.bi.config.OnError(context.Background(), err) |
| 661 | } |
| 662 | return err |
| 663 | } |
| 664 | w.buf.WriteRune('\n') |
| 665 | } |
| 666 | return nil |
| 667 | } |
| 668 | |
| 669 | // flush writes out the worker buffer and handles errors. |
| 670 | // It also restarts the ticker. |