Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added "oncancel" optional chain supported by wf since v0.9.9

  • Loading branch information...
commit 03cc3de2f304efb8f186a55ae84b6d949c4d0273 1 parent c4b6b9a
@kusor authored
Showing with 22 additions and 6 deletions.
  1. +5 −1 lib/tables-definitions.js
  2. +17 −5 lib/workflow-pg-backend.js
View
6 lib/tables-definitions.js
@@ -1,4 +1,4 @@
-// Copyright 2013 Pedro P. Candel <kusorbox@gmail.com>. All rights reserved.
+// Copyright 2014 Pedro P. Candel <kusorbox@gmail.com>. All rights reserved.
module.exports = {
tables: {
@@ -11,6 +11,8 @@ module.exports = {
'max_attempts INTEGER,' +
'chain_md5 VARCHAR(255),' +
'onerror_md5 VARCHAR(255),' +
+ 'oncancel TEXT,' +
+ 'oncancel_md5 VARCHAR(255),' +
'timeout INTEGER)'
],
wf_jobs: [
@@ -21,6 +23,8 @@ module.exports = {
'onerror TEXT,' +
'chain_results TEXT,' +
'onerror_results TEXT, ' +
+ 'oncancel TEXT,' +
+ 'oncancel_results TEXT, ' +
'execution VARCHAR(32) NOT NULL DEFAULT \'queued\' , ' +
'workflow_uuid UUID NOT NULL, ' +
'target VARCHAR(255), ' +
View
22 lib/workflow-pg-backend.js
@@ -1,4 +1,4 @@
-// Copyright 2013 Pedro P. Candel <kusorbox@gmail.com>. All rights reserved.
+// Copyright 2014 Pedro P. Candel <kusorbox@gmail.com>. All rights reserved.
// This module requires some PostgreSQL 9.1+ features
@@ -193,6 +193,14 @@ var WorkflowPgBackend = module.exports = function (config) {
job.onerror_results = JSON.parse(job.onerror_results);
}
+ if (job.oncancel) {
+ job.oncancel = JSON.parse(job.oncancel);
+ }
+
+ if (job.oncancel_results) {
+ job.oncancel_results = JSON.parse(job.oncancel_results);
+ }
+
if (job.params && typeof (job.params) === 'string') {
job.params = JSON.parse(job.params);
}
@@ -295,7 +303,8 @@ var WorkflowPgBackend = module.exports = function (config) {
workflow = {};
row = res.rows[0];
Object.keys(row).forEach(function (p) {
- if (p === 'chain' || p === 'onerror') {
+ if (p === 'chain' || p === 'onerror' ||
+ p === 'oncancel') {
workflow[p] = JSON.parse(row[p]);
} else {
workflow[p] = row[p];
@@ -392,7 +401,8 @@ var WorkflowPgBackend = module.exports = function (config) {
res.rows.forEach(function (row) {
var workflow = {};
Object.keys(row).forEach(function (p) {
- if (p === 'chain' || p === 'onerror') {
+ if (p === 'chain' || p === 'onerror' ||
+ p === 'oncancel') {
workflow[p] = JSON.parse(row[p]);
} else {
workflow[p] = row[p];
@@ -494,7 +504,8 @@ var WorkflowPgBackend = module.exports = function (config) {
var value = null;
var encoded_props = [
'chain', 'chain_results',
- 'onerror', 'onerror_results'
+ 'onerror', 'onerror_results',
+ 'oncancel', 'oncancel_results'
];
var query = 'SELECT (' + prop + ') FROM wf_jobs WHERE uuid=$1';
var vals = [uuid];
@@ -890,7 +901,8 @@ var WorkflowPgBackend = module.exports = function (config) {
'name', 'uuid', 'chain', 'onerrror', 'chain_results',
'onerror_results', 'execution', 'workflow_uuid', 'target',
'params', 'locks', 'exec_after', 'created_at', 'runner_id',
- 'timeout', 'num_attempts', 'max_attempts'
+ 'timeout', 'num_attempts', 'max_attempts', 'oncancel',
+ 'oncancel_results'
];
Object.keys(job).forEach(function (p) {
Please sign in to comment.
Something went wrong with that request. Please try again.