bonifaido / rust-zookeeper

Pure Rust library for Apache ZooKeeper built on MIO
MIT License
204 stars 46 forks source link

Introduce persistent watches #96

Closed behos closed 1 year ago

behos commented 1 year ago

I am opening this pull request to introduce persistent (recursive) watches to the client, since this is one of the missing features right now.

I am making this a draft so that we can discuss the approach.

The idea is to keep two separate pools of watchers since we drop non-persistent watchers on the first event but we want to keep the others. Triggering the watches will remove them from the one-shot list, and keep them in the persistent one. There is an opportunity to refactor the whole way that watchers are managed, but that can be considered separately. (See for example https://github.com/kezhuw/zookeeper-client-rust/blob/master/src/session/watch.rs#L306 where watchers are using channels).

When implementing this I also removed some type duplication for watch types which unfortunately leak into the public API of the library.

I'm not sure whether you would like to proceed with a breaking change or try to keep things backwards compatible by wrapping the Zookeeper types.

bonifaido commented 1 year ago

Hi @behos, I have no objections against breaking the not so fancy API that we have right now, to be more precise on cutting down leaking types! We will bump a version a bit higher, so this library is still pre 1.0 so I think it is okay to make breaking changes in minor version number bumps.

behos commented 1 year ago

Thanks for confirming :)

I added an example with details on how the persistent watchers are used and what to expect from events coming from Zookeeper.

I am marking this as ready for review :D

thibaultmeyer commented 1 year ago

Hello, any news about this merge request ?

bonifaido commented 1 year ago

Cutting a release from this!