用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
# RPC 这里是将SdTcpRpcPool进行了再次封装,需要注意client.php中需要有名为consul的配置方案。 ``` //用于consul微服务的rpc配置 $config['tcpClient']['consul']['set'] = [ 'open_length_check' => 1, 'package_length_type' => 'N', 'package_length_offset' => 0, //第N个字节是包长度的值 'package_body_offset' => 0, //第几个字节开始计算长度 'package_max_length' => 2000000, //协议最大长度 ]; ``` 服务提供商代码MathService ```php /** * RPC Add * @param $one * @param $two */ public function add($one,$two) { $this->send($one+$two); } ``` 服务调用方代码 ```php public function http_testRPC() { $rest = ConsulServices::getInstance()->getRPCService('MathService', $this->context); $reuslt = yield $rest->add(1, 2); $this->http_output->end($reuslt); } ``` 可以通过call函数实现oneway ``` $rest = ConsulServices::getInstance()->getRPCService('MathService', $this->context); $reuslt = yield $rest->call('add',[1, 2],true); $this->http_output->end($reuslt); ```