Greetings, A significant update to gozk, the ZooKeeper bindings for Go, was just released. Among other things, this update includes several small tweaks to Event handling to make it easier to produce correct code.
gozk is an experiment we push as part of Ensemble at Canonical: https://wiki.ubuntu.com/gozk API documentation is available at: http://goneat.org/lp/gozk The following changes and improvements were made. Please read it through as there are incompatible changes. - Event channels will now receive Event rather than *Event. - STATE_CLOSED has been changed to 0 so that events obtained from closed channels can be more easily handled. - Session event channel is now buffered. You should still consume events from it if your application is long-living, though, for processing session expirations with re-connections or panics. If the session channel buffer fills up, the application will panic. - Watch event channels will not receive transient events such as STATE_CONNECTING or STATE_ASSOCIATING anymore, since they disrupt the workflow unnecessarily. These events are still sent to the session event channel, though, and critical events such as STATE_EXPIRED_SESSION are still sent to watch channels. For a full description of how events are now handled, see the documentation: http://goneat.org/lp/gozk#Event - Event now has Ok and String methods. The Ok method returns true if the event reports a usable connection to ZooKeeper, and String enables using critical events as errors. Combined, these methods enable simplified watch handling: event := <-watch if !event.Ok() { err = event return } - Init and ReInit now take parameters in nanoseconds rather than milliseconds, sice that's the most used convention in Go. Make sure you update the calls. - Several functions were renamed for improved styling: zk.GetACL => zk.ACL zk.GetChildren => zk.Children zk.GetChildrenW => zk.ChildrenW zk.GetClientId => zk.ClientId -- Gustavo Niemeyer http://niemeyer.net http://niemeyer.net/plus http://niemeyer.net/twitter http://niemeyer.net/blog -- I never filed a patent.
