Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tabs instead of spaces, js-yaml instead of yaml

  • Loading branch information...
commit fb773e7bf23811211787e29687b07cc4f3f6c472 1 parent 1c3dac5
@pascalopitz authored
View
74 lib/beanstalk_client.js
@@ -1,31 +1,9 @@
// Includes
var events = require('events'),
net = require('net'),
- util = require('util');
-
-// ##yaml wrapper
-// because yaml doesn't like beanstalk
-var yaml = new function() {
- this.eval = function(str) {
- if (!str.replace) {
- return str;
- }
+ util = require('util'),
+ yaml = require('js-yaml');
- // YAML sucks, reg exp to make it working(ish)
- var corrected = str.replace(/\n-\ ([\w\d_-]+)/mig, '\n - \'$1\'') //indent list
- .replace(/(\w)\-(\w)/mgi, '$1_$2') // replace minuses in hash names
- .replace(/\n([\w\d_-]+)\:\ ([\.\,\w\d_-]+)/mig, '\n $1: \'$2\'') // format hashes
- ;
-
- try {
- return require('yaml').eval(corrected);
- } catch(e) {
- Debug.log(e);
- Debug.log(corrected);
- return str;
- }
- };
-};
// ###simple debug console
var Debug = new function() {
@@ -86,7 +64,7 @@ BeanstalkCommand.prototype.responseHandler = function(data, obj, callback) {
}
if(obj.is_yaml) {
- this.emit('command_done', yaml.eval(jobdata));
+ this.emit('command_done', yaml.load(jobdata));
} else {
if(chunks.length > 1) {
chunks.shift();
@@ -137,20 +115,20 @@ BeanstalkClient.prototype.command = function(obj) {
var _self = this;
var cmd = new BeanstalkCommand();
- // makes sure that if there's another command queued, it gets done
- cmd.addListener('command_done', function(data) {
- if(_self.queue.length) {
- var next = _self.queue.shift();
- process.nextTick(function() {
- _self.conn.write(next);
- });
- } else {
- _self.waitingForResponse = false;
- }
+ // makes sure that if there's another command queued, it gets done
+ cmd.addListener('command_done', function(data) {
+ if(_self.queue.length) {
+ var next = _self.queue.shift();
+ process.nextTick(function() {
+ _self.conn.write(next);
+ });
+ } else {
+ _self.waitingForResponse = false;
+ }
});
- // handles data that comes back from the connection
+ // handles data that comes back from the connection
var dataHandler = function(data) {
Debug.log('response:');
Debug.log(data);
@@ -159,20 +137,20 @@ BeanstalkClient.prototype.command = function(obj) {
// pushes commands to the server
var requestExec = function(data) {
- if(!_self.waitingForResponse) {
- _self.waitingForResponse = true;
- Debug.log('request:');
- Debug.log(data);
- process.nextTick(function() {
- _self.conn.write(data);
- });
- } else {
- _self.queue.push(data);
- }
+ if(!_self.waitingForResponse) {
+ _self.waitingForResponse = true;
+ Debug.log('request:');
+ Debug.log(data);
+ process.nextTick(function() {
+ _self.conn.write(data);
+ });
+ } else {
+ _self.queue.push(data);
+ }
};
if(!this.conn) {
- // if there's no connection, create one
+ // if there's no connection, create one
this.conn = net.createConnection(this.port, this.address);
this.conn.setNoDelay();
this.conn.setKeepAlive();
@@ -197,7 +175,7 @@ BeanstalkClient.prototype.command = function(obj) {
Debug.log('connection closed');
});
} else {
- this.conn.removeAllListeners('data');
+ this.conn.removeAllListeners('data');
requestExec(obj.command);
}
View
6 package.json
@@ -2,7 +2,7 @@
"name": "nodestalker"
, "description": "A Beanstalk client for node.js"
, "keywords": ["beanstalkd", "queue"]
- , "version": "0.1.6"
+ , "version": "0.1.7"
, "author": "Pascal Opitz <contact@pascalopitz.com> (http://blog.pascalopitz.com)"
, "repository": {
"type": "git"
@@ -10,10 +10,10 @@
}
, "main": "./lib/beanstalk_client"
, "dependencies": {
- "yaml": ""
+ "js-yaml": ""
}
, "scripts": {
- "test": "find tests/ | grep .js | xargs -n1 node"
+ "test": "find tests/test_*.js | xargs -n1 node"
}
, "licenses":
[{
View
20 tests/test_ignore.js
@@ -7,15 +7,15 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "ignore default\r\n") {
- conn.write('WATCHING');
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ conn.on('data', function(data) {
+ if(String(data) == "ignore default\r\n") {
+ conn.write('WATCHING');
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
@@ -26,7 +26,7 @@ var error = false;
client.ignore('default').onSuccess(function(data) {
console.log(data);
- assert.ok(data);
+ assert.ok(data);
assert.equal(typeof data, 'object');
success = true;
client.disconnect();
View
18 tests/test_kick.js
@@ -7,15 +7,15 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "kick 10\r\n") {
- conn.write('KICKED');
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ conn.on('data', function(data) {
+ if(String(data) == "kick 10\r\n") {
+ conn.write('KICKED');
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
View
26 tests/test_list_tube_used.js
@@ -7,19 +7,19 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "list-tube-used\r\n") {
- var response = 'USING';
- response += "\r\n";
- response += "tube"
- response += "\r\n";
- conn.write(response);
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ conn.on('data', function(data) {
+ if(String(data) == "list-tube-used\r\n") {
+ var response = 'USING';
+ response += "\r\n";
+ response += "tube"
+ response += "\r\n";
+ conn.write(response);
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
View
26 tests/test_list_tubes.js
@@ -7,19 +7,19 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "list-tubes\r\n") {
- var response = 'OK';
- response += "\r\n";
- response += "---\n- default\n - second\n"
- response += "\r\n";
- conn.write(response);
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ conn.on('data', function(data) {
+ if(String(data) == "list-tubes\r\n") {
+ var response = 'OK';
+ response += "\r\n";
+ response += "---\n- default\n - second\n"
+ response += "\r\n";
+ conn.write(response);
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
View
46 tests/test_list_tubes_watched.js
@@ -7,23 +7,23 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "watch default\r\n") {
- conn.write("WATCHING\r\n");
- }
-
- if(String(data) == "list-tubes-watched\r\n") {
- var response = 'OK';
- response += "\r\n";
- response += "---\n- default\n - second\n"
- response += "\r\n";
- conn.write(response);
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ conn.on('data', function(data) {
+ if(String(data) == "watch default\r\n") {
+ conn.write("WATCHING\r\n");
+ }
+
+ if(String(data) == "list-tubes-watched\r\n") {
+ var response = 'OK';
+ response += "\r\n";
+ response += "---\n- default\n - second\n"
+ response += "\r\n";
+ conn.write(response);
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
@@ -32,13 +32,13 @@ var success = false;
var error = false;
client.watch('default').onSuccess(function(data) {
- console.log('watch', data);
+ console.log('watch', data);
- client.list_tubes_watched().onSuccess(function(data) {
- assert.ok(data);
- success = true;
- client.disconnect();
- });
+ client.list_tubes_watched().onSuccess(function(data) {
+ assert.ok(data);
+ success = true;
+ client.disconnect();
+ });
});
client.addListener('error', function() {
View
28 tests/test_multiline_put.js
@@ -7,20 +7,20 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data).indexOf('put') > -1) {
- conn.write("INSERTED 10\r\n");
- }
-
- if(String(data) == 'peek 10\r\n') {
- conn.write("FOUND 10 13\r\ntest\r\nhere\r\n\r\n");
- }
-
- if(String(data) == "delete 10\r\n") {
- conn.write("DELETED\r\n");
- mock_server.close();
- }
- });
+ conn.on('data', function(data) {
+ if(String(data).indexOf('put') > -1) {
+ conn.write("INSERTED 10\r\n");
+ }
+
+ if(String(data) == 'peek 10\r\n') {
+ conn.write("FOUND 10 13\r\ntest\r\nhere\r\n\r\n");
+ }
+
+ if(String(data) == "delete 10\r\n") {
+ conn.write("DELETED\r\n");
+ mock_server.close();
+ }
+ });
});
mock_server.listen(port);
View
58 tests/test_peek_buried.js
@@ -7,39 +7,39 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == 'use burytest\r\n') {
- conn.write("USING\r\n");
- }
+ conn.on('data', function(data) {
+ if(String(data) == 'use burytest\r\n') {
+ conn.write("USING\r\n");
+ }
- if(String(data).indexOf('put') > -1) {
- conn.write("INSERTED 9\r\n");
- }
-
- if(String(data) == 'watch burytest\r\n') {
- conn.write("WATCHING\r\n");
- }
-
- if(String(data) == 'reserve\r\n') {
- conn.write("RESERVED 9 8\r\nburytest\r\n");
- }
+ if(String(data).indexOf('put') > -1) {
+ conn.write("INSERTED 9\r\n");
+ }
+
+ if(String(data) == 'watch burytest\r\n') {
+ conn.write("WATCHING\r\n");
+ }
+
+ if(String(data) == 'reserve\r\n') {
+ conn.write("RESERVED 9 8\r\nburytest\r\n");
+ }
- if(String(data) == 'bury 9 10\r\n') {
- conn.write("BURIED\r\n");
- }
+ if(String(data) == 'bury 9 10\r\n') {
+ conn.write("BURIED\r\n");
+ }
- if(String(data) == 'peek-buried\r\n') {
- conn.write("FOUND 9 8\r\nburytest\r\n");
- }
+ if(String(data) == 'peek-buried\r\n') {
+ conn.write("FOUND 9 8\r\nburytest\r\n");
+ }
- if(String(data) == "delete 9\r\n") {
- conn.write("DELETED\r\n");
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ if(String(data) == "delete 9\r\n") {
+ conn.write("DELETED\r\n");
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
View
18 tests/test_peek_delayed.js
@@ -7,15 +7,15 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == 'peek-delayed\r\n') {
- conn.write("OK\r\n");
- }
- });
-
- conn.on('end', function(){
- mock_server.close();
- })
+ conn.on('data', function(data) {
+ if(String(data) == 'peek-delayed\r\n') {
+ conn.write("OK\r\n");
+ }
+ });
+
+ conn.on('end', function(){
+ mock_server.close();
+ })
});
mock_server.listen(port);
View
34 tests/test_peek_ready.js
@@ -7,23 +7,23 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data).indexOf('put') > -1) {
- conn.write("INSERTED 10\r\n");
- }
-
- if(String(data) == 'peek-ready\r\n') {
- conn.write("FOUND 10 7\r\ntest\r\n");
- }
-
- if(String(data) == 'delete 10\r\n') {
- conn.write("DELETED\r\n");
- }
- });
-
- conn.on('end', function(){
- mock_server.close();
- })
+ conn.on('data', function(data) {
+ if(String(data).indexOf('put') > -1) {
+ conn.write("INSERTED 10\r\n");
+ }
+
+ if(String(data) == 'peek-ready\r\n') {
+ conn.write("FOUND 10 7\r\ntest\r\n");
+ }
+
+ if(String(data) == 'delete 10\r\n') {
+ conn.write("DELETED\r\n");
+ }
+ });
+
+ conn.on('end', function(){
+ mock_server.close();
+ })
});
mock_server.listen(port);
View
44 tests/test_put_in_forloop.js
@@ -9,36 +9,36 @@ var net = require('net');
var cnt = 0;
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data).indexOf('put') > -1) {
- cnt += 1;
- conn.write("INSERTED "+cnt+"\r\n");
- }
-
- if(String(data) == "use default\r\n") {
- conn.write('USING default\r\n');
- mock_server.close();
- }
- });
+ conn.on('data', function(data) {
+ if(String(data).indexOf('put') > -1) {
+ cnt += 1;
+ conn.write("INSERTED "+cnt+"\r\n");
+ }
+
+ if(String(data) == "use default\r\n") {
+ conn.write('USING default\r\n');
+ mock_server.close();
+ }
+ });
});
mock_server.listen(port);
var client = bs.Client('127.0.0.1:' + port);
client.use('default').onSuccess(function(data) {
- var completed = 0;
+ var completed = 0;
- for (var i=0;i<5;i++) {
+ for (var i=0;i<5;i++) {
- client.put("foo", 100, 0).onSuccess(function(data) {
- completed += 1;
- assert.equal(completed, data);
-
+ client.put("foo", 100, 0).onSuccess(function(data) {
+ completed += 1;
+ assert.equal(completed, data);
+
- if(completed === 5) {
- client.disconnect();
- }
- });
- }
+ if(completed === 5) {
+ client.disconnect();
+ }
+ });
+ }
});
View
34 tests/test_put_peek_delete.js
@@ -7,23 +7,23 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data).indexOf('put') > -1) {
- conn.write("INSERTED 10\r\n");
- }
-
- if(String(data) == 'peek 10\r\n') {
- conn.write("FOUND 10 7\r\ntest\r\n");
- }
-
- if(String(data) == 'delete 10\r\n') {
- conn.write("DELETED\r\n");
- }
- });
-
- conn.on('end', function(){
- mock_server.close();
- })
+ conn.on('data', function(data) {
+ if(String(data).indexOf('put') > -1) {
+ conn.write("INSERTED 10\r\n");
+ }
+
+ if(String(data) == 'peek 10\r\n') {
+ conn.write("FOUND 10 7\r\ntest\r\n");
+ }
+
+ if(String(data) == 'delete 10\r\n') {
+ conn.write("DELETED\r\n");
+ }
+ });
+
+ conn.on('end', function(){
+ mock_server.close();
+ })
});
mock_server.listen(port);
View
76 tests/test_put_stats_job_delete.js
@@ -7,40 +7,40 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data).indexOf('put') > -1) {
- conn.write("INSERTED 3\r\n");
- }
+ conn.on('data', function(data) {
+ if(String(data).indexOf('put') > -1) {
+ conn.write("INSERTED 3\r\n");
+ }
- if(String(data) == 'stats-job 3\r\n') {
- response = "";
- response += "OK 141\r\n";
- response += "---\n";
- response += "id: 3\n";
- response += "tube: default\n";
- response += "state: ready\n";
- response += "pri: 10\n";
- response += "age: 0\n";
- response += "delay: 0\n";
- response += "ttr: 100000\n";
- response += "time-left: 0\n";
- response += "reserves: 0\n";
- response += "timeouts: 0\n";
- response += "releases: 0\n";
- response += "buries: 0\n";
- response += "kicks: 0\n";
- response += "\r\n";
- conn.write(response);
- }
+ if(String(data) == 'stats-job 3\r\n') {
+ response = "";
+ response += "OK 141\r\n";
+ response += "---\n";
+ response += "id: 3\n";
+ response += "tube: default\n";
+ response += "state: ready\n";
+ response += "pri: 10\n";
+ response += "age: 0\n";
+ response += "delay: 0\n";
+ response += "ttr: 100000\n";
+ response += "time-left: 0\n";
+ response += "reserves: 0\n";
+ response += "timeouts: 0\n";
+ response += "releases: 0\n";
+ response += "buries: 0\n";
+ response += "kicks: 0\n";
+ response += "\r\n";
+ conn.write(response);
+ }
- if(String(data) == 'delete 3\r\n') {
- conn.write("DELETED\r\n");
- }
- });
-
- conn.on('end', function(){
- mock_server.close();
- })
+ if(String(data) == 'delete 3\r\n') {
+ conn.write("DELETED\r\n");
+ }
+ });
+
+ conn.on('end', function(){
+ mock_server.close();
+ })
});
mock_server.listen(port);
@@ -52,16 +52,16 @@ var error = false;
client.put('test').onSuccess(function(job_data) {
var test_id = job_data[0];
- client.stats_job(test_id).onSuccess(function(data) {
- assert.ok(data);
- assert.ok(data.id);
- assert.equal(test_id, data.id);
- success = true;
+ client.stats_job(test_id).onSuccess(function(data) {
+ assert.ok(data);
+ assert.ok(data.id);
+ assert.equal(test_id, data.id);
+ success = true;
client.deleteJob(test_id).onSuccess(function() {
client.disconnect();
});
- });
+ });
});
client.addListener('error', function() {
View
20 tests/test_quit.js
@@ -7,16 +7,16 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "use default\r\n") {
- conn.write('USING default\r\n');
- }
-
- if(String(data) == "quit\r\n") {
- conn.destroy();
- mock_server.close();
- }
- });
+ conn.on('data', function(data) {
+ if(String(data) == "use default\r\n") {
+ conn.write('USING default\r\n');
+ }
+
+ if(String(data) == "quit\r\n") {
+ conn.destroy();
+ mock_server.close();
+ }
+ });
});
mock_server.listen(port);
View
56 tests/test_reserve.js
@@ -9,36 +9,36 @@ var net = require('net');
var disconnected = 0;
var mock_server = net.createServer(function(conn) {
-
- conn.on('data', function(data) {
- if(String(data) == 'use reservetest\r\n') {
- conn.write("USING\r\n");
- }
+
+ conn.on('data', function(data) {
+ if(String(data) == 'use reservetest\r\n') {
+ conn.write("USING\r\n");
+ }
- if(String(data).indexOf('put') > -1) {
- conn.write("INSERTED 9\r\n");
- }
-
- if(String(data) == 'watch reservetest\r\n') {
- conn.write("WATCHING\r\n");
- }
-
- if(String(data) == 'reserve\r\n') {
- conn.write("RESERVED 9 4\r\ntest\r\n");
- }
+ if(String(data).indexOf('put') > -1) {
+ conn.write("INSERTED 9\r\n");
+ }
+
+ if(String(data) == 'watch reservetest\r\n') {
+ conn.write("WATCHING\r\n");
+ }
+
+ if(String(data) == 'reserve\r\n') {
+ conn.write("RESERVED 9 4\r\ntest\r\n");
+ }
- if(String(data) == "delete 9\r\n") {
- conn.write("DELETED\r\n");
- }
- });
-
- conn.on('end', function() {
- disconnected = disconnected + 1;
-
- if(disconnected == 2) {
- mock_server.close();
- }
- });
+ if(String(data) == "delete 9\r\n") {
+ conn.write("DELETED\r\n");
+ }
+ });
+
+ conn.on('end', function() {
+ disconnected = disconnected + 1;
+
+ if(disconnected == 2) {
+ mock_server.close();
+ }
+ });
});
mock_server.listen(port);
View
20 tests/test_reserve_with_timeout.js
@@ -8,16 +8,16 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
-
- conn.on('data', function(data) {
- if(String(data) == 'reserve-with-timeout 2\r\n') {
- conn.write("RESERVED 9 4\r\ntest\r\n");
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+
+ conn.on('data', function(data) {
+ if(String(data) == 'reserve-with-timeout 2\r\n') {
+ conn.write("RESERVED 9 4\r\ntest\r\n");
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
View
116 tests/test_stats.js
@@ -7,63 +7,63 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == 'stats\r\n') {
- var response = "";
- response += "OK 813\r\n";
- response += "---\n";
- response += "current-jobs-urgent: 0\n";
- response += "current-jobs-ready: 0\n";
- response += "current-jobs-reserved: 0\n";
- response += "current-jobs-delayed: 0\n";
- response += "current-jobs-buried: 0\n";
- response += "cmd-put: 10\n";
- response += "cmd-peek: 2\n";
- response += "cmd-peek-ready: 0\n";
- response += "cmd-peek-delayed: 0\n";
- response += "cmd-peek-buried: 1\n";
- response += "cmd-reserve: 2\n";
- response += "cmd-reserve-with-timeout: 0\n";
- response += "cmd-delete: 10\n";
- response += "cmd-release: 0\n";
- response += "cmd-use: 2\n";
- response += "cmd-watch: 2\n";
- response += "cmd-ignore: 0\n";
- response += "cmd-bury: 1\n";
- response += "cmd-kick: 0\n";
- response += "cmd-touch: 0\n";
- response += "cmd-stats: 1\n";
- response += "cmd-stats-job: 6\n";
- response += "cmd-stats-tube: 0\n";
- response += "cmd-list-tubes: 15\n";
- response += "cmd-list-tube-used: 0\n";
- response += "cmd-list-tubes-watched: 0\n";
- response += "cmd-pause-tube: 0\n";
- response += "job-timeouts: 0\n";
- response += "total-jobs: 10\n";
- response += "max-job-size: 65535\n";
- response += "current-tubes: 1\n";
- response += "current-connections: 1\n";
- response += "current-producers: 0\n";
- response += "current-workers: 0\n";
- response += "current-waiting: 0\n";
- response += "total-connections: 27\n";
- response += "pid: 2759\n";
- response += "version: 1.4.6\n";
- response += "rusage-utime: 0.000000\n";
- response += "rusage-stime: 0.028001\n";
- response += "uptime: 19109\n";
- response += "binlog-oldest-index: 0\n";
- response += "binlog-current-index: 0\n";
- response += "binlog-max-size: 10485760\n";
- response += "\r\n";
- conn.write(response);
- }
- });
-
- conn.on('end', function(){
- mock_server.close();
- })
+ conn.on('data', function(data) {
+ if(String(data) == 'stats\r\n') {
+ var response = "";
+ response += "OK 813\r\n";
+ response += "---\n";
+ response += "current-jobs-urgent: 0\n";
+ response += "current-jobs-ready: 0\n";
+ response += "current-jobs-reserved: 0\n";
+ response += "current-jobs-delayed: 0\n";
+ response += "current-jobs-buried: 0\n";
+ response += "cmd-put: 10\n";
+ response += "cmd-peek: 2\n";
+ response += "cmd-peek-ready: 0\n";
+ response += "cmd-peek-delayed: 0\n";
+ response += "cmd-peek-buried: 1\n";
+ response += "cmd-reserve: 2\n";
+ response += "cmd-reserve-with-timeout: 0\n";
+ response += "cmd-delete: 10\n";
+ response += "cmd-release: 0\n";
+ response += "cmd-use: 2\n";
+ response += "cmd-watch: 2\n";
+ response += "cmd-ignore: 0\n";
+ response += "cmd-bury: 1\n";
+ response += "cmd-kick: 0\n";
+ response += "cmd-touch: 0\n";
+ response += "cmd-stats: 1\n";
+ response += "cmd-stats-job: 6\n";
+ response += "cmd-stats-tube: 0\n";
+ response += "cmd-list-tubes: 15\n";
+ response += "cmd-list-tube-used: 0\n";
+ response += "cmd-list-tubes-watched: 0\n";
+ response += "cmd-pause-tube: 0\n";
+ response += "job-timeouts: 0\n";
+ response += "total-jobs: 10\n";
+ response += "max-job-size: 65535\n";
+ response += "current-tubes: 1\n";
+ response += "current-connections: 1\n";
+ response += "current-producers: 0\n";
+ response += "current-workers: 0\n";
+ response += "current-waiting: 0\n";
+ response += "total-connections: 27\n";
+ response += "pid: 2759\n";
+ response += "version: 1.4.6\n";
+ response += "rusage-utime: 0.000000\n";
+ response += "rusage-stime: 0.028001\n";
+ response += "uptime: 19109\n";
+ response += "binlog-oldest-index: 0\n";
+ response += "binlog-current-index: 0\n";
+ response += "binlog-max-size: 10485760\n";
+ response += "\r\n";
+ conn.write(response);
+ }
+ });
+
+ conn.on('end', function(){
+ mock_server.close();
+ })
});
mock_server.listen(port);
@@ -73,7 +73,7 @@ var success = false;
var error = false;
client.stats().onSuccess(function(data) {
- console.log(data);
+ console.log(data);
assert.ok(data);
assert.ok(data.pid);
assert.equal(typeof data, 'object');
View
18 tests/test_stats_job.js
@@ -7,15 +7,15 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "stats-job 111111111\r\n") {
- conn.write('NOT_FOUND\r\n');
- }
- });
-
- conn.on('end', function() {
- mock_server.close();
- });
+ conn.on('data', function(data) {
+ if(String(data) == "stats-job 111111111\r\n") {
+ conn.write('NOT_FOUND\r\n');
+ }
+ });
+
+ conn.on('end', function() {
+ mock_server.close();
+ });
});
mock_server.listen(port);
View
54 tests/test_stats_tube.js
@@ -7,32 +7,32 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == 'stats-tube default\r\n') {
- var response = "";
- response += "OK 251\r\n";
- response += "---\n";
- response += "name: default\n";
- response += "current-jobs-urgent: 0\n";
- response += "current-jobs-ready: 0\n";
- response += "current-jobs-reserved: 0\n";
- response += "current-jobs-delayed: 0\n";
- response += "current-jobs-buried: 0\n";
- response += "total-jobs: 8\n";
- response += "current-using: 1\n";
- response += "current-watching: 1\n";
- response += "current-waiting: 0\n";
- response += "cmd-pause-tube: 0\n";
- response += "pause: 0\n";
- response += "pause-time-left: 0\n";
- response += "\r\n";
- conn.write(response);
- }
- });
-
- conn.on('end', function(){
- mock_server.close();
- })
+ conn.on('data', function(data) {
+ if(String(data) == 'stats-tube default\r\n') {
+ var response = "";
+ response += "OK 251\r\n";
+ response += "---\n";
+ response += "name: default\n";
+ response += "current-jobs-urgent: 0\n";
+ response += "current-jobs-ready: 0\n";
+ response += "current-jobs-reserved: 0\n";
+ response += "current-jobs-delayed: 0\n";
+ response += "current-jobs-buried: 0\n";
+ response += "total-jobs: 8\n";
+ response += "current-using: 1\n";
+ response += "current-watching: 1\n";
+ response += "current-waiting: 0\n";
+ response += "cmd-pause-tube: 0\n";
+ response += "pause: 0\n";
+ response += "pause-time-left: 0\n";
+ response += "\r\n";
+ conn.write(response);
+ }
+ });
+
+ conn.on('end', function(){
+ mock_server.close();
+ })
});
mock_server.listen(port);
@@ -42,7 +42,7 @@ var success = false;
var error = false;
client.stats_tube('default').onSuccess(function(data) {
- console.log(data);
+ console.log(data);
assert.ok(data);
assert.ok(data.name);
assert.equal(typeof data, 'object');
View
12 tests/test_use.js
@@ -7,12 +7,12 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "use default\r\n") {
- conn.write('USING default\r\n');
- mock_server.close();
- }
- });
+ conn.on('data', function(data) {
+ if(String(data) == "use default\r\n") {
+ conn.write('USING default\r\n');
+ mock_server.close();
+ }
+ });
});
mock_server.listen(port);
View
12 tests/test_watch.js
@@ -7,12 +7,12 @@ var port = 11333;
var net = require('net');
var mock_server = net.createServer(function(conn) {
- conn.on('data', function(data) {
- if(String(data) == "watch default\r\n") {
- conn.write('WATCHING 1\r\n');
- mock_server.close();
- }
- });
+ conn.on('data', function(data) {
+ if(String(data) == "watch default\r\n") {
+ conn.write('WATCHING 1\r\n');
+ mock_server.close();
+ }
+ });
});
mock_server.listen(port);
Please sign in to comment.
Something went wrong with that request. Please try again.