[caption id="attachment_790" align="alignnone" width="220"]RPC描述 RPC描述[/caption] Yar是一个非常轻量级的RPC框架,支持并行处理,下面是安装方式,目前作者没有退出windows版的dll只有linux下可以用,如果您有时间也可以用其重新编译,做成windows版本的! 1.yar的安装 (1)系统需求 php5.2+ curl json (2)安装

  //需要安装phpize ubuntu apt-get install php-dev centos yum install php-devel
  $/path/to/phpize
  $./configure --with-php-config=/path/to/php-config/
  $make && make install
 
2.yar的使用 server端
 
 <?php
class API {
    /**
     * the doc info will be generated automatically into service info page.
     * @params
     * @return
     */
    public function api($parameter, $option = "foo") {
    }
 
    protected function client_can_not_see() {
    }
}
 
$service = new Yar_Server(new API());
$service->handle();
?>
 
用get请求地址接口,效果如下图 yar_server Client端串行调用:
<?php
$client = new Yar_Client("http://host/api/");
$result = $client->api("parameter);
?>
并行调用
<?php
function callback($retval, $callinfo) {
     var_dump($retval);
}
 
Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
Yar_Concurrent_Client::loop(); //send
?>

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部