Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor `KafkaProducer` Motiviation: * align `KafkaProducer` more with proposed changes to `KafkaConsumer` * `AsyncStream` was not handling `AsyncSequence` termination handling as we wanted it to, so revert back to use `NIOAsyncSequenceProducer` Modifications: * make `KafkaProducer` `final class` instead of `actor` * `KafkaProducer`: use `NIOAsyncSequenceProducer` instead of `AsyncSequence` for better termination handling -> shutdown `KafkaProducer` on termination of the `AsyncSequence` * introduce `StateMachine` to `KafkaProducer` * move internal state of `KafkaProducer` to `KafkaProducer.StateMachine` * remove unused `await` expressions when accessing `KafkaProducer` * update tests * update `README` * * rename KafkaProducer.StateMachine.State.shutDown to .finished * Remove unused awaits * KafkaProducer: move logger out of state * KafkaProducer: rename `killPollLoop` -> `terminatePollLoop` * Fix errors after rebase Modifications: * move `NoBackPressure` struct to `extension` of `NIOAsyncSequenceProducerBackPressureStrategies` * break down duplicate `ShutDownOnTerminate` type into two more specialised types for `KafkaConsumer` and `KafkaProducer` * add missing `config` parameter to `KafkaProducer`'s initialiser * Create wrapper for Kafka topic handle dict Modifications: * create new class `RDKafkaTopicHandles` that wraps a dictionary containing all topic names with their respective `rd_kafka_topic_t` handles * create method `KafkaClient.produce` wrapping the `rd_kafka_produce` method in a Swift way * Own implementation of `rd_kafka_flush()` Modifications: * `KafkaClient`: add new property `outgoingQueueSize` * `KafkaProducer.StateMachine`: add new state `.flushing` * `KafkaProducer.shutdownGracefully()`: * make non-async * remove invocation to `rd_kafka_flush` * set state to `KafkaProducer.StateMachine.State` to `.flushing` * `KafkaProducer` poll loop: * poll as long as `outgoingQueueSize` is > 0 to send out any enqueued `KafkaProducerMessage`s and serve any enqueued callbacks * `KafkaProducerTests`: add test asserting that the `librdkafka` `outq` is still being served after `KafkaProducer.shutdownGracefully` has been invoked as long as there are enqueued items * Review Franz Modifications: * rename `KafkaProducer.shutdownGracefully` to `KafkaProducer.triggerGracefulShutdown` * `KafkaProducer.send` separate error message when in state `.flushing`
- Loading branch information