Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connection open/close callbacks #552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oded-zahavi
Copy link

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.

@codecov
Copy link

codecov bot commented Sep 5, 2019

Codecov Report

Merging #552 into master will decrease coverage by 73.67%.
The diff coverage is 33.33%.

Impacted file tree graph

@@             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%) ⬇️
aiokafka/producer/producer.py 23% <50%> (-76.49%) ⬇️
aiokafka/consumer/consumer.py 16.71% <50%> (-82.06%) ⬇️
aiokafka/consumer/group_coordinator.py 9.51% <0%> (-89.66%) ⬇️
aiokafka/consumer/fetcher.py 10.55% <0%> (-86.3%) ⬇️
aiokafka/producer/sender.py 14.54% <0%> (-85%) ⬇️
aiokafka/record/util.py 14.13% <0%> (-84.79%) ⬇️
aiokafka/cluster.py 16.21% <0%> (-83.79%) ⬇️
aiokafka/producer/message_accumulator.py 17.91% <0%> (-80.98%) ⬇️
... 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.

@oded-zahavi oded-zahavi force-pushed the connection_callbacks branch 3 times, most recently from e9adf79 to 61bfdf9 Compare September 16, 2019 22:54
@tvoinarovskyi
Copy link
Member

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.

@oded-zahavi
Copy link
Author

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!

@tvoinarovskyi
Copy link
Member

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.

@oded-zahavi
Copy link
Author

There are multiple ways to achieve that. Could you elaborate?

@oded-zahavi
Copy link
Author

@tvoinarovskyi

@oded-zahavi
Copy link
Author

@tvoinarovskyi ⬆️

@tvoinarovskyi
Copy link
Member

Sorry 😢
I had something like https://aiohttp.readthedocs.io/en/stable/web_advanced.html#signals in mind. What do you think?

@CLAassistant
Copy link

CLA assistant check
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants