Giter Site home page Giter Site logo

straw bug. about straw HOT 6 CLOSED

simonswain avatar simonswain commented on July 25, 2024
straw bug.

from straw.

Comments (6)

wuchuguang avatar wuchuguang commented on July 25, 2024

// 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.

wuchuguang avatar wuchuguang commented on July 25, 2024
// 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.

wuchuguang avatar wuchuguang commented on July 25, 2024

// 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.

wuchuguang avatar wuchuguang commented on July 25, 2024
//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.

wuchuguang avatar wuchuguang commented on July 25, 2024

task ->print output msg:gg
load ->print once load:gg
way load.js process(msg, done) not catch message.

from straw.

simonswain avatar simonswain commented on July 25, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.