diff --git a/src/index.coffee b/src/index.coffee index 42b7749..988c365 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -73,6 +73,15 @@ class ChainGang extends Events.EventEmitter if @active then @perform() + checkStatus: -> + i = 1 + s = [] + now = new Date + for job in @queue + s.push "#{i}: #{job.name} @ #{now - job.created}s ago (#{job.requests})" + i++ + s.join "\n" + # Sets up a timer for the given job, if a timeout is set on the chain. # # job - The new Job instance that is getting the timer. diff --git a/test/chain_gang_test.coffee b/test/chain_gang_test.coffee index 9a982b0..3e98fec 100644 --- a/test/chain_gang_test.coffee +++ b/test/chain_gang_test.coffee @@ -23,6 +23,8 @@ job = chain.index.foo assert.equal 1, job.requests assert.ok job.created? +assert.equal "1: foo @ 0s ago (1)", chain.checkStatus() + # test adding a duplicate item to the queue called = false chain.add null, 'foo' @@ -30,6 +32,8 @@ assert.equal false, called chain.removeListener 'add', cb assert.equal 2, job.requests +assert.equal "1: foo @ 0s ago (2)", chain.checkStatus() + # test adding a 2nd item to the queue called = false a = 0