oxen-queue
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -28,2 +28,4 @@ const crypto = require('crypto') | ||
polling_backoff_rate = 1.1, | ||
onJobSuccess = async () => {}, | ||
onJobError = async () => {} | ||
}) { | ||
@@ -48,2 +50,6 @@ if (!mysql_config) { | ||
/* Callbacks */ | ||
this.onJobError = onJobError | ||
this.onJobSuccess = onJobSuccess | ||
/* Database */ | ||
@@ -219,7 +225,7 @@ this.db = mysql.createPool(mysql_config).promise() | ||
.then(async job_result => { | ||
return _this.handleSuccess({ job_id: job.id, job_result }) | ||
return _this.handleSuccess({ job_id: job.id, job_result, job_body:job.body }) | ||
}) | ||
.catch(async error => { | ||
//job failed | ||
return _this.handleError({ job_id: job.id, error }) | ||
return _this.handleError({ job_id: job.id, error, job_body: job.body }) | ||
}) | ||
@@ -286,3 +292,4 @@ } | ||
async handleSuccess({ job_id, job_result }) { | ||
async handleSuccess({ job_id, job_result, job_body }) { | ||
await this.onJobSuccess({ job_id, job_body, job_type: this.job_type, job_result }) | ||
return this.dbQry( | ||
@@ -309,3 +316,4 @@ ` | ||
async handleError({ job_id, error }) { | ||
async handleError({ job_id, error, job_body }) { | ||
await this.onJobError({ job_id, job_body, job_type: this.job_type, error }) | ||
return this.dbQry( | ||
@@ -312,0 +320,0 @@ ` |
{ | ||
"name": "oxen-queue", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "A resilient worker queue backed by MySQL.", | ||
@@ -5,0 +5,0 @@ "engines": { |
723
57335
11