-
Notifications
You must be signed in to change notification settings - Fork 234
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
feat: rebalance listener added to Consumer constructor #845
base: master
Are you sure you want to change the base?
feat: rebalance listener added to Consumer constructor #845
Conversation
704815f
to
63e93af
Compare
63e93af
to
38d896c
Compare
This pull request introduces 1 alert when merging 38d896c into 6360747 - view on LGTM.com new alerts:
|
38d896c
to
126a307
Compare
This pull request introduces 1 alert when merging 126a307 into 6360747 - view on LGTM.com new alerts:
|
Hi @marcosschroh, |
For example, there can be code, where listener subclasses have "consumer" property, which is not settable. |
Thanks for taking a look. I see 2 problems here:
As you said:
I could see that when I saw the examples and tests. Most of the cases (probably always) you need a link to the consumer from the
class RebalanceListener(ConsumerRebalanceListener):
def __init__(self, consumer): # Always repeat the same
self.consumer = consumer
... There we can see that the end user always has to include the Another problem (out of this scope) is that the interface defines This This change shouldn't affect current users because they are already defining the Other alternative, could be that the callbacks receive the class RebalanceListener(ConsumerRebalanceListener):
async def on_partitions_assigned(self, consumer, tp) -> None
... I hope my explanation makes sense. |
Changes
Fixes #842
ConsumerRebalanceListener
when aConsumer
instance is created.SubscriptionState._validate_rebalance_listener
method.RebalanceListenerCT
(TypeVar) was created. Using this, we can say that the listener should be a subtype of the abstractConsumerRebalanceListener
sphinx_autodoc_typehints
extension was added in order to make possible theTypeVar
documentation. If you prefer not to useTypeVar
we can remove this and theRebalanceListenerCT
Checklist
CHANGES
folder