senecajs / seneca-balance-client

seneca-balance-client
MIT License
18 stars 14 forks source link

Client that are initialized with pins cannot be used by the balance transport #12

Closed mlequain closed 8 years ago

mlequain commented 8 years ago

The send_done function used by the hook_client isn't able to recognize the act pattern and cannot interact/use the clients initialized with a specific pin.

client

const seneca = require('seneca')().use('balance-client');

seneca.client({type: 'balance', pin: 'role:math', port: 22000});
seneca.client({type: 'balance', pin: 'role:math', port: 22001});

for(var i = 0; i < 10; i++){
    seneca.act({role: 'math', cmd: 'add', x: 1}, console.log);
}

server

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

seneca.listen({port: () => process.argv[2]});
seneca.add({role: 'math', cmd: 'add'}, (msg, done) => done(null, {a: 1, x: msg.x}));
nicholaschantcs commented 8 years ago

@mlequain I think I have found a partial solution for your scenario because previously I couldn't define pin at client, and hence I played around with type:'balace' and I had mine fixed.

Try using the code below and and it should work.

client

const seneca = require('seneca')().use('balance-client');
seneca.client({ type: 'balance', pin: 'role:math'});
seneca.client({ pin: 'role:math', port: 22000});
seneca.client({ pin: 'role:math', port: 22001});

for(var i = 0; i < 10; i++){
    seneca.act({role: 'math', cmd: 'add', x: 1}, console.log);
}

server

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

seneca.listen({port: () => process.argv[2]});
seneca.add({role: 'math', cmd: 'add'}, (msg, done) => done(null, {a: 1, x: msg.x}));
mlequain commented 8 years ago

@nicholaschantcs Thanks a lot :) I'll try it asap

rjrodger commented 8 years ago

@mlequain is this still an issue? Please check against latest as pin handling has been refined. In general, it's best to use the same pin on the client and server

mlequain commented 8 years ago

@rjrodger That's my bad, it's now working as intended and i've forgotten to comment on it.

rjrodger commented 8 years ago

awesome!