Kafka/long lived producer - #83
Conversation
08ef23e to
da3334f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
==========================================
+ Coverage 83.65% 83.76% +0.10%
==========================================
Files 13 13
Lines 1328 1337 +9
==========================================
+ Hits 1111 1120 +9
Misses 217 217
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lubomir
left a comment
There was a problem hiding this comment.
I like the general direction. However, I think we should wait with further changes until we confirm in stage that the code is indeed working so that we don't have to chase a moving target.
da3334f to
d4e985a
Compare
|
Kafka long-lived producer, |
|
|
||
| def _kafka_send_msg(msgs): | ||
| """Send messages to Kafka with retry logic. | ||
| _kafka_producer = None |
There was a problem hiding this comment.
There is a race condition risk with this global mutable variable. The main thread could be closing the producer at the same time as the executor thread is trying to publish a message. But the closing happens only at exit, so the race is not really a big deal as the application is shutting down anyway. Once UMB is removed, the threadpool will go to and this problem will mostly go away. Doesn't seem like a huge deal.
Addresses sections 3 and 4 commented on PR #82
3.- There is batching of messages. The producer does this automatically (partially).
4.- The producer is created for each batch of messages. Kafka seems to prefer a long lived producer that is reused.
Comment ref: #82 (review)
Stacked on: #82