Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions esutil/bulk_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ func (w *worker) flush(ctx context.Context) error {
if w.bi.config.OnError != nil {
w.bi.config.OnError(ctx, fmt.Errorf("flush: %s", err))
}
w.notifyItemsOnError(ctx, err)
return fmt.Errorf("flush: %s", err)
}
if res.Body != nil {
Expand All @@ -584,6 +585,7 @@ func (w *worker) flush(ctx context.Context) error {
if w.bi.config.OnError != nil {
w.bi.config.OnError(ctx, fmt.Errorf("flush: %s", res.String()))
}
w.notifyItemsOnError(ctx, err)
return fmt.Errorf("flush: %s", res.String())
}

Expand All @@ -592,6 +594,7 @@ func (w *worker) flush(ctx context.Context) error {
if w.bi.config.OnError != nil {
w.bi.config.OnError(ctx, fmt.Errorf("flush: %s", err))
}
w.notifyItemsOnError(ctx, err)
return fmt.Errorf("flush: error parsing response body: %s", err)
}

Expand Down Expand Up @@ -638,6 +641,14 @@ func (w *worker) flush(ctx context.Context) error {
return err
}

func (w *worker) notifyItemsOnError(ctx context.Context, err error) {
for _, item := range w.items {
if item.OnFailure != nil {
item.OnFailure(ctx, item, BulkIndexerResponseItem{}, fmt.Errorf("flush: %w", err))
}
}
}

type defaultJSONDecoder struct{}

func (d defaultJSONDecoder) UnmarshalFromReader(r io.Reader, blk *BulkIndexerResponse) error {
Expand Down