tx7do / kratos-transport

kratos transport layer extension
MIT License
348 stars 95 forks source link

异步写 kafka 可否把函数也放到 WriterConfig 中? #81

Closed dgqypl closed 5 months ago

dgqypl commented 5 months ago

现在默认是异步写,如果写失败了,应用程序没办法感知到错误,无法对错误做后续处理。

相关代码:

默认是异步写:

https://github.com/tx7do/kratos-transport/blob/5abe8d6a8931bd6f3e6298fea446553852b12f36/broker/kafka/kafka.go#L65

创建 Producer: https://github.com/tx7do/kratos-transport/blob/5abe8d6a8931bd6f3e6298fea446553852b12f36/broker/kafka/writer.go#L112-L128

底层 kafka-go 的回调函数:

https://github.com/segmentio/kafka-go/blob/ebca72eaee918d303c532feb7ff29afdcd8c2efa/writer.go#L161-L182

tx7do commented 5 months ago

妥,最近处理下。

Mew151 @.***> 于2024年5月10日周五 17:12写道:

现在默认是异步写,如果写失败了,应用程序没办法感知到错误,无法对错误做后续处理。

相关代码:

创建 Producer:

https://github.com/tx7do/kratos-transport/blob/5abe8d6a8931bd6f3e6298fea446553852b12f36/broker/kafka/writer.go#L112-L128

底层 kafka-go 的回调方法:

https://github.com/segmentio/kafka-go/blob/ebca72eaee918d303c532feb7ff29afdcd8c2efa/writer.go#L161-L182

— Reply to this email directly, view it on GitHub https://github.com/tx7do/kratos-transport/issues/81, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZKQJCQA3CBVSGYLYYCP3DZBSFQZAVCNFSM6AAAAABHQI4HFCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4DSMZTGUZTKNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>