全部:
当我尝试它的请求-响应https://deepstream.io/示例时,我对Deepstream还是个新手
// remote procedure call for "times-three" with 7
client.rpc.make( "times-three", 7, function( err, result ){
// And get 21 back
console.log( result );
});
// register as a provider
client.rpc.provide( 'times-three', function( num, response ){
// ...and respond to requests
response.send( num * 3 );
});我想知道如果我打开多个名称相同但逻辑不同的提供程序(例如,我将client.rpc.provide放在几个页面中并全部打开),client.rpc.make应该选择哪一个?
谢谢
发布于 2016-10-19 17:53:23
Deepstream通过随机选择顺序提供者来执行负载均衡,提供者被选择来满足RPC,如果提供者不愿意处理它,它可以选择拒绝RPC。
如果您的提供程序执行不同的逻辑,最好将它们命名为不同的名称,以区分调用。类似于对不同的请求使用不同的HTTP路径。
举个例子:
// remote procedure call for "times-three" with 7
client.rpc.make( "times-three", 7, function( err, result ){
// And get 21 back
console.log( result );
});
// this might be triggered, but will always reject it ( for the sake of this example )
client.rpc.provide( 'times-three', function( num, response ){
response.reject();
});
// this will always be triggered, either first or second
client.rpc.provide( 'times-three', function( num, response ){
response.send( num * 3 );
});
// this will never be triggered
client.rpc.provide( 'times-four', function( num, response ){
response.send( num * 4 );
});https://stackoverflow.com/questions/40119490
复制相似问题