Skip to content

Commit

Permalink
fix: pass generic errors to sink handler if preset
Browse files Browse the repository at this point in the history
  • Loading branch information
erayarslan committed May 23, 2024
1 parent aec5947 commit 9e94aec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kafka/producer/producer_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (b *Batch) FlushMessages() {
b.handleMessageTooLargeError(e)
return
default:
b.handleResponseError(e)
logger.Log.Error("batch producer flush error %v", err)
return
}
Expand Down Expand Up @@ -180,6 +181,15 @@ func (b *Batch) handleWriteError(writeErrors kafka.WriteErrors) {
}
}

func (b *Batch) handleResponseError(err error) {
for _, msg := range b.messages {
b.sinkResponseHandler.OnError(&gKafka.SinkResponseHandlerContext{
Message: convertKafkaMessage(msg),
Err: err,
})
}
}

func (b *Batch) handleResponseSuccess() {
for _, msg := range b.messages {
b.sinkResponseHandler.OnSuccess(&gKafka.SinkResponseHandlerContext{
Expand Down

0 comments on commit 9e94aec

Please sign in to comment.