GithubHelp home page GithubHelp logo

greglu / zookeeper_client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emaland/zookeeper_client

5.0 4.0 1.0 810 KB

Ruby wrapper for the ZooKeeper C client library

Home Page: http://github.com/myelin/zookeeper_client

License: MIT License

Ruby 25.93% C 74.07%

zookeeper_client's Introduction

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"

Acquire locks:

  z.try_acquire "/parent/lock-", "content for the lock file" do |have_lock|
    puts have_lock ? "we have the lock" : "we don't have the lock"
  end

zookeeper_client's People

Contributors

myelin avatar

Stargazers

James Chang avatar Gus Becciu avatar Ilya Grigorik avatar Greg Lu avatar Jeff Smick avatar

Watchers

Greg Lu avatar James Cloos avatar James Chang avatar  avatar

Forkers

strategist922

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.