examples/events.js
function create() {
  var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
  var job  = jobs.create( 'video conversion', {
    title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
  } );

  job.on( 'complete', function () {
    console.log( " Job complete" );
  } ).on( 'failed', function () {
    console.log( " Job failed" );
  } ).on( 'progress', function ( progress ) {
    process.stdout.write( '\r  job #' + job.id + ' ' + progress + '% complete' );
  } );

  job.save();

  setTimeout( create, Math.random() * 2000 | 0 );
}
function create() {
  var name = [ 'tobi', 'loki', 'jane', 'manny' ][ Math.random() * 4 | 0 ];
  var job  = jobs.create( 'video conversion', {
    title: 'converting ' + name + '\'s to avi', user: 1, frames: 200
  } );

  job.on( 'complete', function () {
    console.log( " Job complete" );
  } ).on( 'failed', function () {
    console.log( " Job failed" );
  } ).on( 'progress', function ( progress ) {
    process.stdout.write( '\r  job #' + job.id + ' ' + progress + '% complete' );
  } );

  job.save();

  setTimeout( create, Math.random() * 2000 | 0 );
}
function create ( ) { var name = [ 'tobi' , 'loki' , 'jane' , 'manny' ] [ Math . random ( ) * 4 | 0 ] ; var job = jobs . create ( 'video conversion' , { title : 'converting ' + name + '\'s to avi' , user : 1 , frames : 200 } ) ; job . on ( 'complete' , function ( ) { console . log ( " Job complete" ) ; } ) . on ( 'failed' , function ( ) { console . log ( " Job failed" ) ; } ) . on ( 'progress' , function ( progress ) { process . stdout . write ( '\r  job #' + job . id + ' ' + progress + '% complete' ) ; } ) ; job . save ( ) ; setTimeout ( create , Math . random ( ) * 2000 | 0 ) ; }
create some jobs at random, usually you would create these in your http processes upon user input etc.
create some jobs at random usually you would create these in your http processes upon user input etc .