Skip to content

Instantly share code, notes, and snippets.

@stdarg
Created November 7, 2013 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stdarg/7362928 to your computer and use it in GitHub Desktop.
Save stdarg/7362928 to your computer and use it in GitHub Desktop.
fivebeans error case
'use strict';
var fivebeans = require('fivebeans');
var client = new fivebeans.client('127.0.0.1', 11300);
var inspect = require('util').inspect;
var async = require('async');
var jobid;
var data = { a: 'This is a', b: true, c: 55, d: { e: 'This is e.' } };
var str = JSON.stringify(data);
client.on('connect', function() {
console.log('connected');
async.series([ useTube, addJob, addJob2, rmJob ],
function(err) {
if (err) {
console.log('Error: '+inspect(err));
return;
}
console.log('success');
process.exit(0);
});
});
client.on('error', function(err) { console.log('error', err); });
client.on('close', function() { console.log('closed'); });
client.connect();
////////////////////////////////////////////////////////////////////////////////
function useTube(cb) {
client.use('test', function(err, tubename) {
if (err) {
console.log('useTube error: '+inspect(err));
return;
}
console.log('Using tube: '+tubename);
cb();
});
}
function addJob(cb) {
client.put(3, 80000, 999999, str, function(err, id) {
if (err) {
console.log(inspect(err));
return;
}
jobid = id;
console.log('Added job: '+jobid);
cb();
});
}
function addJob2(cb) {
client.put(-33, 80000, 999999, str, function(err, id) {
if (err) {
console.log(inspect(err));
return cb();
}
jobid = id;
console.log('Added job: '+jobid);
cb();
});
}
function rmJob(cb) {
client.destroy(jobid, function(err) {
if (err) {
console.log(jobid,inspect(err));
return cb(err);
}
console.log('Removed job: '+jobid);
cb();
});
}
@stdarg
Copy link
Author

stdarg commented Nov 7, 2013

When you add a job with invalid arguments, in this case priority, destroy fails. Fix the priority, or comment out addJob2, the error goes away. Doing the commands directly with Beanstalkd does not show this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment