No commit activity in last 3 years
No release in over 3 years
zookeeper_client is a Ruby library to interface with the ZooKeeper replicated object store / lock server.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme
zookeeper

An interface to the Zookeeper distributed configuration server.

== License

Copyright 2008 Phillip Pearson, and 2010 Twitter, Inc. Licensed under the
MIT License.  See the included LICENSE file.  Portions copyright 2008-2010
the Apache Software Foundation, licensed under the Apache 2 license, and
used with permission.

== Install

sudo gem install zookeeper

== Usage

Connect to a server:

  require 'rubygems'
  require 'zookeeper'
  z = Zookeeper.new("localhost:2181")

Create, set and read nodes:

  z.create("/bacon", "text to be stored in the new node", 0)
  data, stat = z.get("/bacon")
    # => ["text to be stored in the new node"...]
  
  z.set("/bacon", "an entirely different line of text", stat.version)
  z.set("/bacon", "this won't work", stat.version)
    # CZookeeper::BadVersionError: expected version does not match actual version

  data, stat = z.get("/bacon")
    # => ["an entirely different line of text"...]
  z.delete("/bacon", stat.version)

Create ephemeral and sequence nodes:

  z.create("/parent", "parent node", 0)

  z.create("/parent/test-", 
    "an ordered ephemeral node", 
    Zookeeper::EPHEMERAL | Zookeeper::SEQUENCE)
    # => "/parent/test-0"

  z.create("/parent/test-", 
    "an ordered ephemeral node", 
    Zookeeper::EPHEMERAL | Zookeeper::SEQUENCE)
    # => "/parent/test-1"

  z.get_children(:path => "/")

== Idioms

  The following methods are initially supported:
    get
    set
    get_children
    stat
    create
    delete
    get_acl
    set_acl

  All support async callbacks.  get, get_children and stat support both
  watchers and callbacks.

  Calls take a dictionary of parameters.  With the exception of set_acl, the
  only required parameter is :path.  Each call returns a dictionary with at
  minimum two keys :req_id and :rc.