You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KafkaProducer: replace callbacks with eventPoll (#82)
* `KafkaProducer`: replace callbacks with `eventPoll`
Motivation:
Currently we serve `librdkafka` logs and delivery reports through
callbacks. In the future we also want to get notified about `librdkafka`
triggered errors, statistics and rebalances. As having the callbacks
adds a lot of overhead e.g. by having `Unmanaged` references and having
to wrap Swift closures in C callbacks, we rather want to have an
`eventPoll` method that regularly polls for all sorts of events and
handles them inline.
Modifications:
* `KafkaClient`
* remove `poll` method
* add new method `eventPoll`
* move mapping from `librdkafka` logs to `swift-log` to
`KafkaClient.eventPoll`
* `KafkaProducer`:
* receive acknowledgements through `KafkaClient.eventPoll` instead of using
`KafkaClient.poll` to trigger event callbacks
* replace `deliveryReport` callback and handle deliveryReport event directly in
`KafkaProducer`
* `RDKafkaConfig`
* remove `logging` logic
* `KafkaProducerTests`:
* add `testProducerLog` that asserts that `librdkafka` logs get
forwarded to `swift-log`
* move `convertMessageToAcknowledgementResult` from `RDKafkaConfig` to
`KafkaClient`
* Fix: don't listen to RD_KAFKA_EVENT_DR in non-ack producer
* Review Franz
Modifications:
* `KafkaClient.eventPoll`:
* reserve capacity for arrays to avoid
reallocations
* move `rd_kafka_event_destory` to `defer` statement
* get rid of named loop (just return from loop)
* wrap handling of different event types in `private` methods
* wrap subset of `RD_KAFKA_*` event types in Swift type `RDKafkaEvent`
0 commit comments