Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Benson Lin
    @icebro_gitlab

    hi , i am just try to custom my logger and check this tutorials/logging-with-seneca
    http://senecajs.org/docs/tutorials/logging-with-seneca.html

    but got this error

    D:\code\seneca-log-test\sales-tax-log-handler.js:8
    {level: 'all', handler: seneca.loghandler.file('shop.log')}
    ^

    TypeError: Cannot read property 'file' of undefined
    at Object.<anonymous> (D:\code\seneca-log-test\sales-tax-log-handler.js:8:49)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)

    at bootstrap_node.js:625:3

    ================================
    any sugguestion?

    José da Mata
    @josemf
    hi guys, I've a general question about concurrent service operation calls
    does Seneca handles concurrent requests from clients
    I'm defining a few modules that will listen requests from clients, and one of those generates PDF using a puppeteer integration
    I'm not sure how much load this operation will have to handle in the future, but I'm worried if seneca will be able to this with a TCP transport (no queuing) on a "default" settings basis
    José da Mata
    @josemf
    Do you guys know how to measure this on seneca? I'm also wondering about what would be the best practice for approaching scalability issues
    Thank you guys!
    Fran
    @Paker30
    hi guys Does any have issues register pins with the latest version of seneca-mesh? I've upgrade and I can't register pines, I try to register new pines with chairo
    Luiz Carlos Muniz
    @lcmuniz_twitter
    Hi guys. Can you help me? A would like to know if more the one seneca microservice can respond to the same message. I tried to write two microservices that respond to the same message but was not able to do so. I am new in seneca programming.
    Shyam Pratap Singh
    @spsingh559
    @lcmuniz_twitter can you bit specified what actually you want to achieve. Microservices respond based on the pattern defined, if you want the same message should be received by two different microservices, create a two Seneca client with two different patterns and send the message.
    Shyam Pratap Singh
    @spsingh559

    https://github.com/spsingh559/microserviceTemplate

    This is reference implementation of Seneca microservices along with API hosted on node js server. It may help to see the entire Seneca flow.

    Luiz Carlos Muniz
    @lcmuniz_twitter
    Let's say I have a microservice that sends a message with the pattern "type:client,cmd:list", what I am asking is if two other microservices that listen to "type:client,cmd:list" pattern can respond. I am asking this because I implemented this scenario and only one of them is replying, the other is not. It is like if the first that receives the message consumes it and the other does not receive. You said that I have to create two microservices with to diferent patterns, but I want to microservices thar respond to the same pattern. Maybe I am not doing right. Like I said, I am using seneca for the first time.
    Shyam Pratap Singh
    @spsingh559

    Seneca Microservices discover each other using mesh network, once you publish a message, mesh find out the best matching pattern and deliver the message to the corresponding microservice.
    So you are right, anyone will respond out of two if defined by the same pattern.

    But if your use case is to send the same message to two microservices, as I said " use two different patterns" something like this "type:client, cmd:message" and "type:client, cmd:duplicateMessage".

    And conceptually one microservice should do one dedicated task, assigning two MS to process similar tasks is not desirable.

    Stephan Kennedy
    @ks32849
    Having problems with seneca prior while following seneca-in-practice. I'm getting:
    Error: seneca: The prior method must be called inside an action function. Arguments were: [Arguments]
    when running this:
    module.exports = function(options) {
        this.add({role: 'math', cmd: 'sum'}, (msg, done) => {
            done(null, {answer: msg.left + msg.right});
        });
    
        this.add({role: 'math', cmd: 'product'}, (msg, done) => {
            done(null, {answer: msg.left * msg.right});
        });
    
        this.add({role: 'math', cmd: 'sum', integer: true}, (msg, done) => {
            done(null, {answer: Math.floor(msg.left) + Math.floor(msg.right)});
        });
    
        this.add({role: 'math', cmd: 'sum'}, (msg, done) => {
            if (isFinite(msg.left) && isFinite(msg.right)) {
                this.prior({role: 'math', cmd: 'sum', left: msg.left, right: msg.right}, (err, result) => {
                    if( err ) return done( err );
                    result.info =  msg.left + ' + ' + msg.right;
                    done(null, result);
                });
            }
            else {
                done(new Error('Expected left and right to be numbers.'), null);
            }
        });
    
        return 'operations';
    }
    Shyam Pratap Singh
    @spsingh559

    @ks32849 I don't know why are you defining role:'math',cmd:'sum' twice, its already been declared on top.
    And since you are not over riding any function, prior has no use here and unless and until you want one function to handle multiple use case. Check the proper uses of prior function along with right syntax here

    https://senecajs.org/docs/tutorials/understanding-prior-actions.html

    Shyam Pratap Singh
    @spsingh559

    const seneca=require('seneca')();

    seneca
    .add({role: 'math', cmd: 'sum'}, function(msg, done){ //declaring without arrow function
    done(null, {answer: msg.left + msg.right});
    })

    .add({role: 'math', cmd: 'product'}, function(msg, done) { //declaring without arrow function
        done(null, {answer: msg.left * msg.right});
    })
    
    .add({role: 'math', cmd: 'sum', integer: true}, function(msg, done) { //declaring without arrow function
        done(null, {answer: Math.floor(msg.left) + Math.floor(msg.right)});
    })
    
    .add({role: 'math', cmd: 'sum'}, function(msg, done)  { //declaring without arrow function
        if (isFinite(msg.left) && isFinite(msg.right)) {
            this.prior(msg, (err, result) => { //pass the message object only, no need to pass pattern
                if( err ) return done( err );
                result.info =  msg.left + ' + ' + msg.right;
                done(null, result);
            });
        }
        else {
            done(new Error('Expected left and right to be numbers.'), null);
        }
    })
    
    //testing the role math, cmd: sum service
    .act({role: 'math', cmd: 'sum',left: 10, right: 5},function (err,output){
        console.log(err,output); //null { answer: 15, info: '10 + 5' }
    })
    @ks32849 this is working code, which can be tested with prior

    @ks32849 your updated code, i hope this works for you.

    module.exports = function(options) {
    this.add({role: 'math', cmd: 'sum'}, function(msg, done) {
    done(null, {answer: msg.left + msg.right});
    });

    this.add({role: 'math', cmd: 'product'}, function(msg, done) {
        done(null, {answer: msg.left * msg.right});
    });
    
    this.add({role: 'math', cmd: 'sum', integer: true}, function(msg, done) {
        done(null, {answer: Math.floor(msg.left) + Math.floor(msg.right)});
    });
    
    this.add({role: 'math', cmd: 'sum'}, function(msg, done) {
        if (isFinite(msg.left) && isFinite(msg.right)) {
            this.prior(msg, (err, result) => {
                if( err ) return done( err );
                result.info =  msg.left + ' + ' + msg.right;
                done(null, result);
            });
        }
        else {
            done(new Error('Expected left and right to be numbers.'), null);
        }
    });
    
    return 'operations';

    }

    Stephan Kennedy
    @ks32849
    Thanks @spsingh559 - seems the issue is this.prior is only valid if the callback in add is defined as an inline function and not an arrow function.
    Shyam Pratap Singh
    @spsingh559
    yeah, right
    Karnphong Kieoprasert
    @karnphongkie
    How can I use middleware with seneca-web in the example seem not works.
    using express.
    Shyam Pratap Singh
    @spsingh559
    can u post the sample code or link for reference @karnphongkie ?
    Karnphong Kieoprasert
    @karnphongkie
    Thank @spsingh559 I have solved by add middleware in the route.
    RAJAT
    @rajatprogrammer
    anybody know how to connect seneca without define a rabbit Mq port
    I have cloud service of rabbit mq in which port is managed by the service itself i am not able to connect seneca with that cloud hosted rabbit Mq
    Stephan Kennedy
    @ks32849
    Seems that the --seneca.print.tree option is no longer working as in the getting started docs (https://senecajs.org/getting-started/). Is there a replacement or another way to show the tree?
    Shyam Pratap Singh
    @spsingh559

    @rajatprogrammer could you please elaborate more on the issue.

    I have tried replicating the problem as far as i understand

    created a docker rabbitmq docker image from here https://www.rabbitmq.com/download.html

    now created a Seneca listener and seneca client as mentioned here https://github.com/senecajs/seneca-amqp-transport

    Note : My URL is : amqp://guest:guest@127.0.0.1:5672/

    which means for my user name and password is guest:guest and connected local instance of Rabbit MQ 127.0.0.1 ( you can replace with cloud IP) with 5672 port and vhost is "/" . Make sure 5672 port is open in cloud service

    and here are the results :

    Screen Shot 2020-12-17 at 10.25.05 PM.png
    image.png

    listner is

    image.png

    Shyam Pratap Singh
    @spsingh559
    @ks32849 even I am wondering why trees logs are not shown. Maybe this logging feature got deprecated, not sure of it.