-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
{ | ||
"host": "127.0.0.1", | ||
"database": "pgboss", | ||
"user": "postgres", | ||
"password": "postgres", | ||
"schema": "pgboss", | ||
"uuid": "v1", | ||
"newJobCheckIntervalSeconds": 1, | ||
"expireCheckIntervalMinutes": 1, | ||
"expireCheckIntervalSeconds": 60, | ||
"archiveCheckIntervalMinutes": 60, | ||
"archiveCompletedJobsEvery": "1 day" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
var assert = require('chai').assert; | ||
var PgBoss = require('../lib/index'); | ||
var config = require('./config.json'); | ||
var helper = require('./testService'); | ||
|
||
describe('retries', function() { | ||
it('should retry a job that didn\'t complete', function (finished) { | ||
|
||
var expireIn = '1 second'; | ||
var retries = 2; | ||
|
||
this.timeout(7000); | ||
|
||
// todo: temp test for travis config override | ||
if(process.env.TRAVIS) { | ||
config.port = 5433; | ||
config.password = ''; | ||
} | ||
|
||
config.expireCheckIntervalSeconds = 1; | ||
|
||
var boss = new PgBoss(config); | ||
|
||
boss.on('error', logError); | ||
boss.on('ready', ready); | ||
|
||
boss.start(); | ||
|
||
function logError(error) { | ||
console.error(error); | ||
} | ||
|
||
function ready() { | ||
helper.init() | ||
.then(test); | ||
} | ||
|
||
function test() { | ||
var subscribeCount = 0; | ||
|
||
boss.subscribe('unreliable', null, function(job, done) { | ||
// not calling done so it will expire | ||
subscribeCount++; | ||
}); | ||
|
||
boss.publish('unreliable', null, { | ||
expireIn: expireIn, | ||
retryLimit: retries | ||
}); | ||
|
||
setTimeout(function() { | ||
assert.equal(subscribeCount, retries + 1); | ||
finished(); | ||
|
||
}, 6000); | ||
} | ||
|
||
}); | ||
}); |