Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Doozer client for node.js
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
schema first crappy stab at parsing responses
test
.gitignore
index.js
package.json
readme.md

readme.md

Doozer.js

A node.js client driver for Doozer

Requirements

Doozer.js requires the pbuf Protocol Buffers module, which requires protobuf to be installed in /usr/local

Usage

Add doozer to your package.json

{
    "dependencies": {
        "doozer": "~0.1"
    }
}

Then:

var Doozer = require('doozer')

API

Doozer.dial(port, host, [callback])

Connect to a Doozerd server on the given host and port. Returns a Doozer connection object.

Arguments

  • port - server port number to connect to.
  • host - server host to connect to. Either an IP string or host name
  • callback() - An optional callback for the 'connect' event.

Example

Doozer.dial(8046, "localhost", function () {
    console.log("connected to Doozer")
});

Doozer.dial(address, [callback])

Same as above except address is a string like "localhost:8047". If no port is given 8046 will be assumed.


Doozer.dialUri(uri, [buri], callback)

Connect to a Doozer cluster using a doozer:? uri string, optionally using DzNS for node lookup. See Doozer URIs for details

Note, this function DOES NOT return a Doozer object. It is available as this in the callback.

Arguments

  • uri - a "doozer:?" uri with either ca or cn parameters.
  • buri - an optional "doozer:?" uri to the DzNS server
  • callback(err) - A required callback for the 'connect' event.

Example

Doozer.dialUri("doozer:?cn=local", "doozer:?ca=10.0.1.5:8048", function (err) {
    this.rev(function(err, rev) {
        console.log(rev)
    })
})

rev(callback)

Return the current rev number

Arguments

  • callback(err, rev) - returns the rev number on success

set(path, oldRev, value, callback)

Sets a value for the given file

Arguments

  • path - path to the file to set
  • oldRev - rev number this path had before
  • value - the value to set
  • callback(err, rev) - returns the new rev number on success

get(path, [rev], callback)

Get the value at the given path

Arguments

  • path - path to the file
  • rev - optional rev number of the value to get. Defaults to newest rev
  • callback(err, value, rev) - returns the value and rev number on success

del(path, rev, callback)

Delete the given path with the given rev number

Arguments

  • path - the path to delete
  • rev - the rev to delete
  • callback(err, response)

getDir(dir, offset, limit, [rev], callback)

Gets the names of the children of the given dir

Arguments

  • dir - the path to a directory (must not be a file)
  • offset - skips this number of child records, should usually be 0
  • limit - max number of child names to return, use -1 for no limit
  • rev - optional rev number
  • callback(err, names) - returns an array of child node names on success

getDirInfo(dir, offset, limit, [rev], callback)

Like getDir except returns an array of StatInfo instead of names


stat(path, [rev], callback)

Returns the file length and rev number at the given path

Arguments

  • path - path to a file
  • rev - optional rev number
  • callback(err, length, rev) - returns the length and rev on success

statInfo(path, [rev], callback)

Return an object with stat information on the given path. A StatInfo contains:

  • len
  • rev
  • name
  • isSet
  • isDir

Arguments

  • path - path to a file or directory
  • rev - optional rev number
  • callback(err, statInfo) - returns a statInfo object on success

wait(glob, rev, callback)

Registers the given callback to be called when a file covered by glob meets or exceeds the given rev.

Arguments

  • glob - a path pattern to watch. see Glob Notation
  • rev - the rev to watch for
  • callback(err, response)

close()

Closes the connection to Doozer


Something went wrong with that request. Please try again.