Skip to content

Instantly share code, notes, and snippets.

@DTrejo
Created April 9, 2012 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DTrejo/2346472 to your computer and use it in GitHub Desktop.
Save DTrejo/2346472 to your computer and use it in GitHub Desktop.
API thoughts for zookeeper mkdir -p
//
// How would you prefer to use a mkdir-p API?
// Note that this is for making directories in ZooKeeper :)
//
//
// Option #1
//
var mkdirp = require('zk-mkdirp');
var connection = new ZooKeeper(/* ... */);
mkdirp(connection, path, callback);
//
// Option #2
// more complicated to program, and possibly bad b/c require is sync, and
// users might want to create the connection to zookeeper after the first tick
// of the event loop.
//
var connection = new ZooKeeper(/* ... */);
var mkdirp = require('zk-mkdirp')(connection);
mkdirp(path, callback);
//
// Option #3
// best of both worlds? just plain awkward if you only use it once?
//
var mkdirp = require('zk-mkdirp');
var connection = new ZooKeeper(/* ... */);
mkdirp.connection = connection;
mkdirp(path, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment