Description
Currently, if Writer
is in async mode, ie: WriterConfig.Async == true
, any errors that occur when writing the messages to kafka are ignored. It would be nice for a variety of use cases to have visibility of these errors while in async mode. I'd specifically like visibility so I can process failed messages and possibly send to dead-letter queue without losing the niceties of sending asynchronously.
As a possible implementation, I was thinking of adding an errors channel (chan WriterError
) which a client can read from retrieve the errors. The channel would be buffered and the size would be controlled by the WriterConfig. Sarama has something similar, see https://github.com/Shopify/sarama/blob/6e063e619ea7e2bd19a18782a3c727cf0d6b0c3e/async_producer.go#L47
Clients will need to read from the error channel otherwise it will block the partitionWriters. This functionality would need to be completely optional.
#401 will provide the error type needed to support this so it feels like a natural enhancement to make. Interested to hear feedback