Description
你好,服务端不管使用Socket的TCP版本或者是swoole的tcp版本
定义了两个rpc服务,其中一个有耗时处理请求,一个没有
客户端定义两个路由接口,分别用http\Client `同步调用,先调用耗时服务请求后,再调用无耗时的方法,无耗时的方法永远都要等待耗时服务处理完才能返回结果,请问两个方法同时访问服务的时候,如果是swoole的不是会协程接管请求跟响应吗?怎么解决这个问题?
RpcServer
`use Hprose\Swoole\Server;
class RpcServer
{
public function init(){
$services = config('rpc_service.');
if(!$services){
throw new \Exception('rpc_service config empty');
}
$server = new Server('tcp://0.0.0.0:8777');
$server->setDebugEnabled(true); // 开启调试
foreach($services as $cls => $prefix){
$server->addInstanceMethods(new $cls,'',$prefix);
}
$server->addFilter(new AuthFilter());
$server->start();
}
}`
RpcClient
Route::get('rpc_test',function(){ $client = new Hprose\Socket\Client('tcp://192.168.3.251:8777', false); // $client = app\lib\rpcClient\RpcClient::getClient(); $client->addFilter(new app\lib\rpcClient\client\AuthFilter()); return $client->test_sub(5,10); }); Route::get('rpc_calc',function(){ $client = new Hprose\Socket\Client('tcp://192.168.3.251:8777', false); // $client = app\lib\rpcClient\RpcClient::getClient(); $client->addFilter(new app\lib\rpcClient\client\AuthFilter()); return $client->calc_concat('a','c'); });