Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: elastic error handler #18

Merged
merged 1 commit into from
May 28, 2024
Merged
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
24 changes: 12 additions & 12 deletions internal/impl/elasticsearch/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,19 +427,19 @@ func (e *Output) WriteBatch(ctx context.Context, msg service.MessageBatch) error

e.log.Errorf("Elasticsearch message '%v' rejected with status [%v]: %v\n", item.Id, item.Status, reason)
if !shouldRetry(item.Status) {
return fmt.Errorf("failed to send message '%v': %v", item.Id, reason)
msg[i].SetError(fmt.Errorf("failed to send message '%v': %v", item.Id, reason))
} else {
// IMPORTANT: i exactly matches the index of our source requests
// and when we re-run our bulk request with errored requests
// that must remain true.
sourceReq := requests[i]
bulkReq, err := e.buildBulkableRequest(sourceReq)
if err != nil {
return err
}
b.Add(bulkReq)
newRequests = append(newRequests, sourceReq)
}

// IMPORTANT: i exactly matches the index of our source requests
// and when we re-run our bulk request with errored requests
// that must remain true.
sourceReq := requests[i]
bulkReq, err := e.buildBulkableRequest(sourceReq)
if err != nil {
return err
}
b.Add(bulkReq)
newRequests = append(newRequests, sourceReq)
}
}
requests = newRequests
Expand Down