Yar并行的RPC框架
Yar 是一個支持多種打包協(xié)議的, 并行的RPC框架.
它基于HTTP協(xié)議, 在libcurl基礎(chǔ)上開發(fā)而成
簡單的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();
- ?>
簡單調(diào)用:
- $client = new Yar_Client("http://host/api/");
- $result = $client->api("parameter);
- ?>
并行調(diào)用:
- 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
評論
圖片
表情
