Module: ZK::Client

Defined in:



ACL support is pretty much unused currently. If anyone has suggestions, hints, use-cases, examples, etc. by all means please file a bug.

A ruby-friendly wrapper around the low-level zookeeper drivers.

You're probably looking for Base and Threaded.

Once you've had a look there, take a look at Conveniences, StateMixin, and Unixisms

Defined Under Namespace

Modules: Conveniences, StateMixin, Unixisms Classes: Base, Threaded

Constant Summary collapse


Class Method Summary collapse

Class Method Details

.new(*a) {|self| ... } ⇒ Threaded


The :timeout argument here is not the session_timeout for the connection. rather it is the amount of time we wait for the connection to be established. The session timeout exchanged with the server is set to 10s by default in the C implemenation, and as of version 0.8.0 of slyphon-zookeeper has yet to be exposed as an option. That feature is planned.


The documentation for 0.9.0 was incorrect in stating the number of threads used to deliver events. There was one, unconfigurable, event dispatch thread. In 1.0 the number of event delivery threads is configurable, but still defaults to 1 and users are discouraged from adjusting the value due to the complexity this introduces. In 1.1 there is a better option for achieving higher concurrency (see the :thread option)

The Management apologizes for any confusion this may have caused.

Construct a new threaded client.

Pay close attention to the :threaded option, and have a look at the EventDeliveryModel page in the wiki for a discussion of the relative advantages and disadvantages of the choices available. The default is safe, but the alternative will likely provide better performance.


  • host (String)

    should be a string of comma-separated host:port pairs. You can also supply an optional "chroot" suffix that will act as an implicit prefix to all paths supplied.


  • (self)

    calls the block with the new instance after the event handler and threadpool have been set up, but before any connections have been made. This allows the client to register watchers for session events like connected. You cannot perform any other operations with the client as you will get a NoMethodError (the underlying connection is nil).


See Also:


  • 1.1: Instead of adjusting the threadpool, users are strongly encouraged to use the :thread => :per_callback option to increase the parallelism of event delivery safely and sanely. Please see this wiki article for more information and a demonstration.

# File 'lib/zk/client.rb', line 27

def new(*a, &b)*a, &b)