Skip to content

Commit

Permalink
Add ack script
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Romero Brox committed Jun 3, 2013
1 parent 3e77609 commit 6d41c0e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions utils/ack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

'use strict';

var program = require('commander'),

This comment has been minimized.

Copy link
@aitormagan

aitormagan Jun 4, 2013

Contributor

commander should be added to package.json

request = require('request'),
util = require('util'),
i,
url,
trans;

program
.version('0.0.1')
.option('-H, --host [hostname]', 'host, \'localhost\' by default', 'localhost')
.option('-P, --port [number]', 'port, 5001 by default', 5001, parseInt)
.option('-Q, --queue [id]', 'queue', "Q1")
.option('-T, --trans [list]', 'list of transactions separated by comma', list)
.option('-X, --secure', 'use HTTPS', false)
.parse(process.argv);
url = util.format('%s://%s:%d/queue/%s/ack', program.secure?'https':'http', program.host, program.port, program.queue);
trans = {
'transactions': program.trans
};

console.log('url\n', url);
console.log('trans\n', trans);
request.post({url : url, json: trans}, function(err, res, body) {
if(err) {
console.log('error\n', err);
}
else {
console.log('statusCode\n', res.statusCode);
console.log('headers\n', res.headers);
console.log('body\n', body);
}
});
function range(val) {
return val.split('..').map(Number);
}
function list(val) {
return val.split(',');
}

0 comments on commit 6d41c0e

Please sign in to comment.