Created
November 7, 2013 22:24
-
-
Save stdarg/7362928 to your computer and use it in GitHub Desktop.
fivebeans error case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.