aiokafka
aiokafka copied to clipboard
Add connection open/close callbacks
What do these changes do?
Add new callbacks for connection opened/close for consumer and producer
Are there changes in behavior for the user?
User may add callbacks if they want to be notified for changes in connection status (and take action accordingly)
Related issue number
No
Checklist
- [x ] I think the code is well written
- [ x] Unit tests for the changes exist
- [ x] Documentation reflects the changes
- [ x] Add a new news fragment into the
CHANGES
folder- name it
<issue_id>.<type>
(e.g.588.bugfix
) - if you don't have an
issue_id
change it to the pr id after creating the PR - ensure type is one of the following:
-
.feature
: Signifying a new feature. -
.bugfix
: Signifying a bug fix. -
.doc
: Signifying a documentation improvement. -
.removal
: Signifying a deprecation or removal of public API. -
.misc
: A ticket has been closed, but it is not of interest to users.
-
- Make sure to use full sentences with correct case and punctuation, for example:
Fix issue with non-ascii contents in doctest text files.
- name it
Codecov Report
Merging #552 into master will decrease coverage by
73.67%
. The diff coverage is33.33%
.
@@ Coverage Diff @@
## master #552 +/- ##
===========================================
- Coverage 98.42% 24.74% -73.68%
===========================================
Files 31 31
Lines 5017 5035 +18
===========================================
- Hits 4938 1246 -3692
- Misses 79 3789 +3710
Impacted Files | Coverage Δ | |
---|---|---|
aiokafka/client.py | 14.81% <20%> (-83.28%) |
:arrow_down: |
aiokafka/producer/producer.py | 23% <50%> (-76.49%) |
:arrow_down: |
aiokafka/consumer/consumer.py | 16.71% <50%> (-82.06%) |
:arrow_down: |
aiokafka/consumer/group_coordinator.py | 9.51% <0%> (-89.66%) |
:arrow_down: |
aiokafka/consumer/fetcher.py | 10.55% <0%> (-86.3%) |
:arrow_down: |
aiokafka/producer/sender.py | 14.54% <0%> (-85%) |
:arrow_down: |
aiokafka/record/util.py | 14.13% <0%> (-84.79%) |
:arrow_down: |
aiokafka/cluster.py | 16.21% <0%> (-83.79%) |
:arrow_down: |
aiokafka/producer/message_accumulator.py | 17.91% <0%> (-80.98%) |
:arrow_down: |
... and 13 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update c0fa11f...1334b5d. Read the comment docs.
Good day, thanks for looking to contribute. Can you explain the use case, where you need to have this callback? Maybe there's a more generic solution for those cases.
Hi @tvoinarovskyi the purpose is to provide the calling application with connection status change indication, in order to allow it to take more actions if needed (such as, but not limited to, event log for instance). I have look thoroughly into the code and could not figure out an elegant way to do that. Callbacks, as suggested, would be a very nice and elegant way to do that. I've tried to write tests for it but figured it would be hard to simulate a change in connection status, and mocking it would be simply not interesting enough. It would be grate to have your opinion!
I would prefer some reusable generic interface for similar cases. In java client they have this concept of Interceptors. I would consider something similar instead of adding callbacks for all cases.
There are multiple ways to achieve that. Could you elaborate?
@tvoinarovskyi
@tvoinarovskyi ⬆️
Sorry 😢 I had something like https://aiohttp.readthedocs.io/en/stable/web_advanced.html#signals in mind. What do you think?
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.