Yar 是一个支持多种打包协议的, 并行的RPC框架.
简单的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
发布于 2017-03-22 23:30:06 | 137 次阅读