Created
April 9, 2012 20:50
-
-
Save DTrejo/2346472 to your computer and use it in GitHub Desktop.
API thoughts for zookeeper mkdir -p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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