PHP并行 RPC 框架,Yar-1.0.0 发布
jopen 12年前
Yar-1.0.0发布 目前文档暂缺。http://pecl.php.net/package/yar
Yar 是一个支持多种打包协议的, 并行的RPC框架.
它基于HTTP协议, 在libcurl基础上开发而成
简单的Server:
- 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();
- ?>
简单调用:
- $client = new Yar_Client("http://host/api/");
- $result = $client->api("parameter);
- ?>
并行调用:
- 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
- ?>
更多信息参看: Yar at Github