public
Created

API thoughts for zookeeper mkdir -p

  • Download Gist
proposal.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//
// 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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.