-
Notifications
You must be signed in to change notification settings - Fork 131
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
Global EventNotWatching events for session lost #34
Conversation
Codecov Report
@@ Coverage Diff @@
## master #34 +/- ##
==========================================
- Coverage 77.58% 77.06% -0.52%
==========================================
Files 7 7
Lines 1316 1317 +1
==========================================
- Hits 1021 1015 -6
- Misses 205 211 +6
- Partials 90 91 +1
Continue to review full report at Codecov.
|
Sorry for the late review, I will have a look at this one today. #35 already has some feedback which I agree with. There is no "one" owner of this fork. |
Thank you! |
All session state changes are sent to the global even channel. For example when a session expires: https://github.com/go-zookeeper/zk/blob/master/conn.go#L677 The Is it really needed to send it to the global event channel? |
This one is for individual watches being lost. Our use case is a "tree watcher" style helper library -- (https://github.com/fullstorydev/gosolr/blob/master/solrmonitor/zkwatcherman.go) that tries to avoid duplicating state in memory that the zk client is already holding. Instead of tracking a billion individual channels and using a massive (and unscalable) reflective select over them, we're using the global event channel so we can listen on a single channel and get all events. This works 99% perfectly-- all events sent to individual watch channels are also sent to the global channel. Except for this one case! For our use, it's not enough to get a single global event for session lost-- we need to know the paths of all the lost watches. Without this event, we'd have to duplicate the map of watched nodes in our wrapper helper, which is a waste of memory. |
Wanted to ping on this and see if we could drive this forward. This feature is vital to being able to implement a high-scale watcher that can reestablish watches after a ZK session lost. |
Apologies for the late review. The change lgtm, an additional review is welcomed though.
I wonder what the original client's behavior is. Shouldn't they be re added by the client library? |
Awesome!
If you're talking about We wrote a little library that sits on top of zk.Conn and handles the task of watching certain ZK nodes, pushing updates out to the app, and re-establishing watches whenever an event fires. This library use to use the individual |
No, I was talking about the Java original client or how other clients deal with watchers on reconnect. |
Oh, good question. I haven't used the Java ZK client in a long time. It looks like the Java client only has global watch event callbacks. Its API is not like Go, it doesn't offer per-method watch callbacks. |
So this PR should actually bring Go closer to Java in that regard! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
All other events are published to the global event callback; but lost session events are not. These events are essential to correctly implement cross-cutting wrapper frameworks that do things like re-add watches when a new session is obtained.