Comments (6)
// start.js
let straw = require('straw');
const strawInstrance = straw.create({nodes_dir:__dirname + "/nodes"});
strawInstrance.add([
{
id:'image-task',
node:'node-image-task',
input: 'image-out',
output: 'task-out'
},
{
id:'image-load',
node:'node-image-load',
input: 'task-out',
output: 'image-out'
}
],function(){
strawInstrance.start();
});
from straw.
// nodes/node-image-load.js
let straw = require('straw');
module.exports = straw.node({
start: function(done) {
done(false);
},
stop: function(done) {
done(false);
},
process:function(msg, done){
console.log("load:" + msg);
}
});
from straw.
// nodes/node-image-task.js
let straw = require('straw');
let redis = require('../redis');
const redisInstrance = redis();
module.exports = straw.node({
opts: {interval: 1000},
initialize: function(opts, done){
this.opts.interval = opts && opts.interval || 1000;
done();
},
start: function(done) {
this.timer = setInterval(this.loadRedis.bind(this), this.opts.interval);
done(false);
},
stop: function(done) {
clearInterval(this.timer);
done(false);
},
loadRedis: function() {
redisInstrance.spop(gconst.redis_image_queque, (err, msg)=>{
if(msg){
console.log('output msg:' + msg);
this.output(msg);
}
})
},
process:function(msg, done){
console.log(msg);
}
});
from straw.
//print
% node start_straw.js
info: 2016-08-12 12:35:22 ADD image-task
info: 2016-08-12 12:35:22 INIT image-task 1871
info: 2016-08-12 12:35:22 MESSAGE image-task INITIALIZED
info: 2016-08-12 12:35:22 ADD image-load
info: 2016-08-12 12:35:22 INIT image-load 1887
info: 2016-08-12 12:35:22 MESSAGE image-load INITIALIZED
info: 2016-08-12 12:35:22 MESSAGE image-task STARTING
info: 2016-08-12 12:35:22 STARTED image-task
info: 2016-08-12 12:35:22 MESSAGE image-task STARTED
info: 2016-08-12 12:35:22 MESSAGE image-load STARTING
info: 2016-08-12 12:35:22 STARTED image-load
info: 2016-08-12 12:35:22 TOPOLOGY STARTED
info: 2016-08-12 12:35:22 MESSAGE image-load STARTED
info: 2016-08-12 13:43:30 STDOUT image-task output msg:gg
info: 2016-08-12 13:43:30 STDOUT image-load load:gg
info: 2016-08-12 13:43:39 STDOUT image-task output msg:gg
info: 2016-08-12 13:43:40 STDOUT image-task output msg:gg
info: 2016-08-12 13:43:41 STDOUT image-task output msg:gg
info: 2016-08-12 13:43:42 STDOUT image-task output msg:gg
info: 2016-08-12 13:43:43 STDOUT image-task output msg:gg
info: 2016-08-12 13:43:44 STDOUT image-task output msg:gg
info: 2016-08-12 13:44:41 STDOUT image-task output msg:gg
info: 2016-08-12 13:44:47 STDOUT image-task output msg:gg
from straw.
task ->print output msg:gg
load ->print once load:gg
way load.js process(msg, done) not catch message.
from straw.
Might take me a few days but I'll try and look at this shortly. Thanks for the info.
from straw.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from straw.