Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

feed flow example updated

  • Loading branch information...
commit b592ad88dd9035057fdb98ebb4633225c7948b92 1 parent ce21009
@openmason authored
View
17 examples/feedflow.js
@@ -1,17 +0,0 @@
-var cloudd = require('../index');
-
-// workflow definition:
-// tasks are defined in individual files - methods could be task/done/failed/progress
-// configuration the task graph looks:
-// root -> 'fetch feeds' -> 'fetch articles' -> 'save articles'
-var flow = [
- {id:'fetch feeds', task: require('./tasks/feed'), parent:'root'},
- {id:'fetch articles', task: require('./tasks/article'), parent:'fetch feeds'},
- {id:'save articles', task: require('./tasks/upload'), parent:'fetch articles'}
-];
-
-// submit job at given cron config
-// lets try submitting one every minute
-cloudd.submitAt('* * * * * *', 'feeder', flow);
-cloudd.startapp(3000);
-
View
8 examples/tasks/article.js
@@ -1,9 +1,5 @@
-exports.task = function(job, done) {
- console.log('fetch article');
+exports.task = function(task, done) {
+ console.log('fetch articles');
done();
};
-exports.done = function() {
- console.log('completed fetching articles');
-};
-
View
21 examples/tasks/feed.js
@@ -1,26 +1,13 @@
var taskname='[feed]';
-// create feed tasks
-// return array of task configs [ {id, title, config}, {id, title, config}, ... ]
-exports.create = function(taskid) {
- var feeds = [
- {name:'bbc', url:'http://newsrss.bbc.co.uk/rss/path...to..xml'}
- ];
- var taskconfigs = [];
- for(var i=0;i<feeds.length;i++) {
- var taskconfig = {id:taskid+':'+feeds[i].name, title: taskid+':'+feeds[i].name, config: feeds[i].url};
- taskconfigs.push(taskconfig);
- }
- return taskconfigs;
-};
-
/**
* fetch the feed articles, feed is passed as config
* in the job
*/
-exports.task = function(job, done) {
- var feed = job.data.config;
- console.log("%s %s - %s", taskname, job.type, feed);
+exports.task = function(task, done) {
+ //var feed = job.data.config;
+ //console.log("%s %s - %s", taskname, task.id, feed);
+ console.log("inside fetching feeds");
done();
};
View
5 examples/tasks/filter.js
@@ -0,0 +1,5 @@
+exports.task = function(task, done) {
+ console.log('filter articles');
+ done();
+};
+
View
7 examples/tasks/tag.js
@@ -0,0 +1,7 @@
+var taskname='[tag]';
+
+exports.task = function(task, done) {
+ console.log('inside tag and save');
+ done();
+};
+
View
5 examples/tasks/upload.js
@@ -1,5 +0,0 @@
-exports.task = function(job, done) {
- console.log('upload articles to database');
- done();
-};
-
View
1  lib/cloudd.js
@@ -85,7 +85,6 @@ exports.start = function(port) {
socket.send(JSON.stringify(res));
break;
case 'cron':
- console.log('inside cron');
res = {result:'cron submitted:'+obj.id};
try {
exports.submitAt(obj.cron, obj.id, to.load(obj.config));
View
6 todo.md
@@ -1,5 +1,9 @@
## List of todos
- * specify the javascript file with method to execute
+ * specify port, workers in cloud config file
+ * pre-fork those many workers
+ * if already a job is present with same name or task with same job/taskid reject task/job
+ * example of feeds to be fixed
+ * need to re-load the js files if a new job is submitted?
* start child workers in a cluster for javascript
* validate the config file
* in config file - allow specifying log files for stdout, stderr

0 comments on commit b592ad8

Please sign in to comment.
Something went wrong with that request. Please try again.