jubaclient
Advanced tools
Comparing version 0.2.4 to 0.2.5
10
index.js
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
const jubatus = require('jubatus'); | ||
const rpc = require('jubatus/lib/msgpack-rpc'); | ||
const rpc = require('msgpack-rpc-lite'); | ||
const app = require('./app'); | ||
@@ -35,3 +35,3 @@ | ||
const client = rpc.createClient(port, host, timeout); | ||
const client = rpc.createClient(port, host, timeout, { encode: { useraw: true } }); | ||
@@ -82,3 +82,7 @@ let count = 0; | ||
completions = Object.keys(jubatus); | ||
completions = Object.keys(jubatus) | ||
.map(namespace => Object.keys(jubatus[namespace].client)) | ||
.reduce((accumulator, current) => accumulator.concat(current)) | ||
.map(className => className.replace(/^([A-Z])/, (match) => match.toLowerCase())) | ||
.map(app.toSnakeCase); | ||
question(rl, `service [${ service }]: `).then(serviceName => { | ||
@@ -85,0 +89,0 @@ service = serviceName || service; |
{ | ||
"name": "jubaclient", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Jubatus CLI client (unofficial)", | ||
@@ -31,4 +31,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"jubatus": "^0.7.1", | ||
"minimist": "^1.2.0" | ||
"jubatus": "~0.7.4", | ||
"minimist": "^1.2.0", | ||
"msgpack-rpc-lite": "~0.0.3" | ||
}, | ||
@@ -35,0 +36,0 @@ "devDependencies": { |
@@ -6,40 +6,38 @@ const expect = require('chai').expect; | ||
const portfinder = require('portfinder'); | ||
const rpc = require('jubatus/lib/msgpack-rpc'); | ||
const rpc = require('msgpack-rpc-lite'); | ||
const app = require('../app'); | ||
function createServerProcess(command, config, timeoutSeconds = 10, regex = /RPC server startup/) { | ||
const option = { port: Number(process.env.npm_package_config_test_port || 9199) }; | ||
return portfinder.getPortPromise(option).then(port => { | ||
debug(`port: ${ port }`); | ||
return new Promise((resolve, reject) => { | ||
const args = [ '-p', port, '-f', config ], options = { cwd: __dirname }; | ||
resolve([port, spawn(command, args, options) ]); | ||
}); | ||
}).then(([ port, serverProcess ]) => { | ||
const executor = (resolve, reject) => { | ||
const timeout = timers.setTimeout(() => { | ||
serverProcess.kill(); | ||
reject(new Error('timeout!')); | ||
}, timeoutSeconds * 1000); | ||
serverProcess.on('exit', (code, signal) => { | ||
debug({ code, signal }); | ||
if (code === null) { | ||
reject(new Error(signal)); | ||
timers.clearTimeout(timeout); | ||
} | ||
}); | ||
serverProcess.stdout.on('data', data => { | ||
if (regex.test(data.toString())) { | ||
resolve([ port, serverProcess ]); | ||
timers.clearTimeout(timeout); | ||
} | ||
}); | ||
if (debug.enabled) { | ||
const option = { port: Number(process.env.npm_package_config_test_port || 9199) }; | ||
return portfinder.getPortPromise(option).then(port => { | ||
debug(`port: ${ port }`); | ||
const args = [ '-p', port, '-f', config ], options = { cwd: __dirname }; | ||
return [ port, spawn(command, args, options) ]; | ||
}).then(([ port, serverProcess ]) => { | ||
const executor = (resolve, reject) => { | ||
const timeout = timers.setTimeout(() => { | ||
serverProcess.kill(); | ||
reject(new Error('timeout!')); | ||
}, timeoutSeconds * 1000); | ||
serverProcess.on('exit', (code, signal) => { | ||
debug({ code, signal }); | ||
if (code === null) { | ||
reject(new Error(signal)); | ||
timers.clearTimeout(timeout); | ||
} | ||
}); | ||
serverProcess.stdout.on('data', data => { | ||
process.stderr.write(data); | ||
if (regex.test(data.toString())) { | ||
resolve([ port, serverProcess ]); | ||
timers.clearTimeout(timeout); | ||
} | ||
}); | ||
} | ||
}; | ||
return new Promise(executor); | ||
}); | ||
if (debug.enabled) { | ||
serverProcess.stdout.on('data', data => { | ||
process.stderr.write(data); | ||
}); | ||
} | ||
}; | ||
return new Promise(executor); | ||
}); | ||
} | ||
@@ -90,3 +88,3 @@ | ||
}).catch(done); | ||
}); | ||
}); | ||
}); | ||
@@ -93,0 +91,0 @@ |
22363
11
306
3
+ Addedmsgpack-rpc-lite@~0.0.3
Updatedjubatus@~0.7.4