Socket
Socket
Sign inDemoInstall

fash

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fash - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

1

159

bin/fash.js

@@ -12,2 +12,3 @@ #!/usr/bin/env node

var fash = require('../lib/index');
var fs = require('fs');
var util = require('util');

@@ -84,2 +85,160 @@

Fash.prototype.do_add_data = function(subcmd, opts, args, callback) {
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
if (args.length !== 0 || !opts.v || !opts.f) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
var topology = fs.readFileSync(opts.f, 'utf8');
var chash = fash.deserialize({topology: topology});
var vnodes = opts.v.split(' ');
vnodes.forEach(function(vnode, index) {
chash.addData(parseInt(vnode, 10), opts.d);
if (index === vnodes.length - 1) {
console.log(chash.serialize());
}
});
return (undefined);
};
Fash.prototype.do_add_data.options = [{
names: [ 'f', 'topology' ],
type: 'string',
help: 'the topology to modify'
}, {
names: [ 'v', 'vnode' ],
type: 'string',
help: 'the vnode(s) to add the data to'
}, {
names: [ 'd', 'data' ],
type: 'string',
help: 'the data to add, optional, if empty, removes data from the node'
}];
Fash.prototype.do_add_data.help = (
'add data to a vnode.\n'
+ '\n'
+ 'usage:\n'
+ ' fash add_data [options] \n'
+ '\n'
+ '{{options}}'
);
Fash.prototype.do_remap_vnode = function(subcmd, opts, args, callback) {
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
if (args.length !== 0 || !opts.v || !opts.f || !opts.p) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
var topology = fs.readFileSync(opts.f, 'utf8');
var chash = fash.deserialize({topology: topology});
var vnodes = opts.v.split(' ');
for (var i = 0; i < vnodes.length; i++) {
vnodes[i] = parseInt(vnodes[i], 10);
}
chash.remapVnode(opts.p, vnodes);
console.log(chash.serialize());
return (undefined);
};
Fash.prototype.do_remap_vnode.options = [{
names: [ 'f', 'topology' ],
type: 'string',
help: 'the topology to modify'
}, {
names: [ 'v', 'vnode' ],
type: 'string',
help: 'the vnode(s) to remap'
}, {
names: [ 'p', 'pnode' ],
type: 'string',
help: 'the pnode to remap the vnode(s) to'
}];
Fash.prototype.do_remap_vnode.help = (
'remap a vnode to a different pnode.\n'
+ '\n'
+ 'usage:\n'
+ ' fash remap_vnode [options] \n'
+ '\n'
+ '{{options}}'
);
Fash.prototype.do_remove_pnode = function(subcmd, opts, args, callback) {
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
if (args.length !== 0 || !opts.f || !opts.p) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
var topology = fs.readFileSync(opts.f, 'utf8');
var chash = fash.deserialize({topology: topology});
chash.removePnode(opts.p);
console.log(chash.serialize());
return (undefined);
};
Fash.prototype.do_remove_pnode.options = [{
names: [ 'f', 'topology' ],
type: 'string',
help: 'the topology to modify'
}, {
names: [ 'p', 'pnode' ],
type: 'string',
help: 'the pnode to remap the vnode(s) to'
}];
Fash.prototype.do_remove_pnode.help = (
'remove a pnode'
+ '\n'
+ 'usage:\n'
+ ' fash remove_pnode [options] \n'
+ '\n'
+ '{{options}}'
);
Fash.prototype.do_get_node = function(subcmd, opts, args, callback) {
if (opts.help) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
if (args.length !== 1 || !opts.f) {
this.do_help('help', {}, [subcmd], callback);
return (callback());
}
var topology = fs.readFileSync(opts.f, 'utf8');
var chash = fash.deserialize({topology: topology});
console.log(chash.getNode(args[0]));
return (undefined);
};
Fash.prototype.do_get_node.options = [{
names: [ 'f', 'topology' ],
type: 'string',
help: 'the hash ring topology'
}];
Fash.prototype.do_get_node.help = (
'hash a value to its spot on the ring'
+ '\n'
+ 'usage:\n'
+ ' fash get_node [options] value\n'
+ '\n'
+ '{{options}}'
);
cmdln.main(Fash); // mainline

4

lib/consistent_hash.js

@@ -368,3 +368,3 @@ /**

var errMsg = 'pnode still maps to vnodes, re-assign vnodes first';
throw new new verror.VError(errMsg);
throw new verror.VError(errMsg);
}

@@ -404,3 +404,3 @@

if (!vnodes) {
log.warn('pnode is not in ring', pnode);
log.error('pnode is not in ring', pnode);
throw new verror.VError('pnode is not in ring', pnode);

@@ -407,0 +407,0 @@ }

@@ -18,3 +18,3 @@ {

],
"version": "1.2.1",
"version": "1.2.2",
"repository": {

@@ -21,0 +21,0 @@ "type": "git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc