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

propgate 'CLOSED' event to client, so it can know extactly when the conn... #15

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

Conversation

villadora
Copy link

...ection is closed and register callback #14

@alexguan
Copy link
Owner

This library is try to match Java zookeeper client convention. There is no CLOSED state for zookeeper, the client is either connected or trying to reconnect.

After invoking close method on the client object, you don't need to wait for the event from ConnectionManager since the client object cannot be reused again.

Let me know if you have specific reasons, otherwise I will close this PR in couple of days.

@villadora
Copy link
Author

My situation is like following:

I had to handle SESSION_EXPIRED event in my app, I kept the watchers myself; So when I found a expired event, I try to close the old zkClient gracefully and sweep my app, so that I can create new client for the needs.

Just like in many other languages, java, scala, etc. If a session expires, the zookeeper client will close() the now 'dead' zk handle and create a new instance essentially establishing a new session.

But the problem is I don't know when the close() work is done, in java the close() method is synchronically, which is not here.

I'm not sure what will happen if I left the old 'dead' zk there and just remove reference to that old zkClient. But that may cause a lot of 'dead' zk client in the app if the network has problem to make the new zkClient expired too.

That's why I need to know when the house is cleaned up, if the event api need to be consistency to java, what about to make the close() function accept a callback, so people can do things after the client is really closed.

Thank you very much!

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.

2 participants