MCPcopy
hub / github.com/elastic/go-elasticsearch / writeBody

Method writeBody

esutil/bulk_indexer.go:650–667  ·  view source on GitHub ↗

writeBody writes the item body to the buffer.

(item *BulkIndexerItem)

Source from the content-addressed store, hash-verified

648
649// writeBody writes the item body to the buffer.
650func (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.

Callers 1

runMethod · 0.95

Calls 1

SeekMethod · 0.80

Tested by

no test coverage detected