nacos簡(jiǎn)單客戶端

v1.0.4
版本
2023-09-20
版本更新時(shí)間
30
安裝
4
star
簡(jiǎn)單的php版本nacos客戶端
安裝
composer require xiaosongshu/nacos
客戶端提供的方法
$dataId = 'CalculatorService';
$group = 'api';
$serviceName = 'mother';
$namespace = 'public';
$client = new \Xiaosongshu\Nacos\Client('http://127.0.0.1:8848','nacos','nacos');
/** 發(fā)布配置 */
print_r($client->publishConfig($dataId, $group, json_encode(['name' => 'fool', 'bar' => 'ha'])));
/** 獲取配置 */
print_r($client->getConfig($dataId, $group));
/** 監(jiān)聽(tīng)配置 */
print_r($client->listenerConfig($dataId, $group, json_encode(['name' => 'fool', 'bar' => 'ha'])));
/** 刪除配置 */
print_r($client->deleteConfig($dataId, $group));
/** 創(chuàng)建服務(wù) */
print_r($client->createService($serviceName, $namespace, json_encode(['name' => 'tom', 'age' => 15])));
/** 創(chuàng)建實(shí)例 */
print_r($client->createInstance($serviceName, "192.168.4.110", '9504', $namespace, json_encode(['name' => 'tom', 'age' => 15]), 99, 1, false));
/** 獲取服務(wù)列表 */
print_r($client->getServiceList($namespace));
/** 服務(wù)詳情 */
print_r($client->getServiceDetail($serviceName, $namespace));
/** 獲取實(shí)例列表 */
print_r($client->getInstanceList($serviceName, $namespace));
/** 獲取實(shí)例詳情 */
print_r($client->getInstanceDetail($serviceName, false, '192.168.4.110', '9504'));
/** 發(fā)送心跳 */
print_r($client->sendBeat($serviceName, '192.168.4.110', 9504, $namespace, false, 'beat'));
/** 移除實(shí)例*/
print_r($client->removeInstance($serviceName, '192.168.4.110', 9504, $namespace, false));
/** 刪除服務(wù) */
print_r($client->removeService($serviceName, $namespace));