Yar - 并行的RPC框架


PHP license
跨平台
C/C++

软件简介

Yar 是一个支持多种打包协议的, 并行的RPC框架.

它基于HTTP协议, 在libcurl基础上开发而成

简单的Server:

      1.   2. class API {
  3.     /**
  4.      * the doc info will be generated automatically into service info page.
  5.      * @params
  6.      * @return
  7.      */
  8.     public function api($parameter, $option = "foo") {
  9.     }
  10.  
  11.     protected function client_can_not_see() {
  12.     }
  13. }
  14.  
  15. $service = new Yar_Server(new API());
  16. $service->handle();
  17. ?>

简单调用:

      1.   2. $client = new Yar_Client("http://host/api/");
  3. $result = $client->api("parameter);
  4. ?>

并行调用:

      1.   2. function callback($retval, $callinfo) {
  3.      var_dump($retval);
  4. }
  5.  
  6. Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
  7. Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
  8. Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
  9. Yar_Concurrent_Client::call("http://host/api/", "api", array("parameters"), "callback");
  10. Yar_Concurrent_Client::loop(); //send
  11. ?>

更多信息参看: Yar at Github