Skip to content

Commit 86c4e56

Browse files
committed
Refactoring
1 parent b9a52e6 commit 86c4e56

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

examples/RemoteJobs/functions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ var spawn = require('child_process').spawn;
22

33
// Spawns a job "node handler.js" and waits for the notification of its
44
// completion using the Redis job status notification mechanism
5-
async function job_status_redis_test(ins, outs, context, cb) {
5+
async function submitRemoteJob(ins, outs, context, cb) {
66
var n = Number(ins.number.data[0]);
77

88
//console.log("Spawning process...");
99

10-
const executable = context.executor.executable;
10+
const executable = context.command.executable;
1111
let jobMessage = JSON.stringify({
1212
"executable": executable,
13-
"args": context.executor.args,
14-
"env": (context.executor.env || {}),
13+
"args": context.command.args,
14+
"env": context.command.env || {},
1515
"inputs": ins.map(i => i),
1616
"outputs": outs.map(o => o),
17-
"stdout": context.executor.stdout, // if present, denotes file name to which stdout should be redirected
17+
"stdout": context.command.stdout, // if present, denotes file name to which stdout should be redirected
1818
"redis_url": context.redis_url,
1919
"taskId": context.taskId
2020
});
@@ -55,4 +55,4 @@ async function job_status_redis_test(ins, outs, context, cb) {
5555
}
5656
}
5757

58-
exports.job_status_redis_test = job_status_redis_test;
58+
exports.submitRemoteJob = submitRemoteJob;

examples/RemoteJobs/handler.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ var getJobMessage = async function (timeout) {
2020
return new Promise(function (resolve, reject) {
2121
const jobMsgKey = taskId + "_msg";
2222
rcl.brpop(jobMsgKey, timeout, function (err, reply) {
23-
if (err) reject(err)
24-
else {
25-
resolve(reply);
26-
}
23+
err ? reject(err): resolve(reply)
2724
});
2825
});
2926
}
@@ -32,10 +29,7 @@ var getJobMessage = async function (timeout) {
3229
var notifyJobCompletion = async function () {
3330
return new Promise(function (resolve, reject) {
3431
rcl.rpush(taskId, "OK", function (err, reply) {
35-
if (err) reject(err)
36-
else {
37-
resolve(reply);
38-
}
32+
err ? reject(err): resolve(reply)
3933
});
4034
});
4135
}

examples/RemoteJobs/workflow.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"name": "RedisNotificationTestWorkflow",
2+
"name": "RemoteJobsTestWorkflow",
33
"processes": [ {
4-
"name": "RedisNotificationTest",
4+
"name": "SubmitRemoteJob",
55
"type": "dataflow",
66
"parlevel": 0,
77
"firingLimit": 100,
8-
"function": "job_status_redis_test",
8+
"function": "submitRemoteJob",
99
"config": {
10-
"executor": {
11-
"executable": "echo",
12-
"args": ["Hello", "world"]
13-
}
10+
"command": {
11+
"executable": "echo",
12+
"args": ["Hello", "world"]
13+
}
1414
},
1515
"ins": [ "number" ],
1616
"outs": [ ]
1717
} ],
1818
"signals": [ {
19-
"name": "number",
19+
"name": "number",
2020
"data": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 ]
2121
} ],
2222
"ins": [ "number" ],

0 commit comments

Comments
 (0)