PHP code example of caasdata / tars-registry
1. Go to this page and download the library: Download caasdata/tars-registry library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
caasdata / tars-registry example snippets
├── composer.json
├── src
│ ├── client //请求主控服务的client代码
│ │ ├── Code.php
│ │ ├── CodeRegistry.php
│ │ ├── CommunicatorConfig.php
│ │ ├── CommunicatorFactory.php
│ │ ├── Communicator.php
│ │ ├── CommunicatorRegistry.php
│ │ ├── Consts.php
│ │ ├── RequestPacket.php
│ │ ├── RequestPacketRegistry.php
│ │ ├── ResponsePacket.php
│ │ ├── ResponsePacketRegistry.php
│ │ ├── TUPAPIWrapper.php
│ │ └── TUPAPIWrapperRegistry.php
│ ├── EndpointF.php //struct EndpointF 的php类
│ ├── QueryFServant.php //直接请求主控服务
│ ├── QueryFWrapper.php //优先从内存寻找服务地址,其次从主控寻址
│ ├── RouteTable.php //在swoole table里保存服务地址
│ └── tars //协议文件
│ ├── EndpointF.tars
│ └── QueryF.tars
└── tests
└── demo.php
//从tarsregistry服务寻找服务地址
$wrapper = new \Tars\registry\QueryFWrapper("tars.tarsregistry.QueryObj@tcp -h 172.16.0.161 -p 17890",1,60000);
$result = $wrapper->findObjectById("PHPTest.PHPServer.obj");
var_dump($result);
//优先从内存寻找服务地址,其次从主控寻址
\Tars\registry\RouteTable::getInstance();
$result = \Tars\registry\RouteTable::getRouteInfo("PHPTest.PHPServer.obj");
echo "result:\n";
var_dump($result);