What is it?

The gozk project enables Go programs to communicate with a ZooKeeper cluster.

It was developed within Canonical as part of an experiment related to using the Go language with the juju project.

API documentation

The API documentation is currently available at:

Example

Here is a simple example which connects to ZooKeeper, waits for the session to be established, and attempts to create a node:

package main

import (
    "launchpad.net/gozk"
)

func main() {
    zk, session, err := gozk.Init("localhost:2181", 5000)
    if err != nil {
        println("Couldn't connect: " + err.String())
        return
    }

    defer zk.Close()

    // Wait for connection.
    event := <-session
    if event.State != gozk.STATE_CONNECTED {
        println("Couldn't connect")
        return
    }

    _, err = zk.Create("/counter", "0", 0, gozk.WorldACL(gozk.PERM_ALL))
    if err != nil {
        println(err.String())
    } else {
        println("Created!")
    }
}

Installing

Assuming you have the ZooKeeper library and headers installed in your system (tested with Ubuntu), you can use goinstall:

$ sudo apt-get install libzookeeper-dev
$ goinstall launchpad.net/gozk

Source code

To obtain the source code, use Bazaar to download it from Launchpad:

$ bzr branch lp:gozk

Reporting bugs

Please report bugs at:

Running tests

To run tests, you'll have to define at least the $ZKROOT environment variable, and point it to the root of your ZooKeeper source build ($ZKROOT/bin/zkServer.sh should exist).

Then, install gocheck:

$ goinstall launchpad.net/gocheck

Once that's in place, and any other necessary environment variables are defined (see above), run tests with gotest as usual:

$ gotest

Note that a ZooKeeper server will be dynamically started and stopped by the test suite.

License

gozk is licensed under the LGPL.

Contact

This project is being developed under the Ensemble project at Canonical.

To get in touch, send a message to the Ensemble mailing list at: <ensemble@lists.ubuntu.com>

gozk (last edited 2012-09-24 22:20:18 by 173-164-68-213-Oregon)