php使用consul,topphp/topphp-consul - Packagist

README

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f707068702f746f707068702d636f6e73756c2e7376673f7374796c653d666c61742d737175617265

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265

68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f707068702f746f707068702d636f6e73756c2f6d61737465722e7376673f7374796c653d666c61742d737175617265

68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f707068702f746f707068702d636f6e73756c2e7376673f7374796c653d666c61742d737175617265

68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f707068702f746f707068702d636f6e73756c2e7376673f7374796c653d666c61742d737175617265

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f707068702f746f707068702d636f6e73756c2e7376673f7374796c653d666c61742d737175617265

#服务中心客户端

topphp提供了一个consul组件,基于 topphp/topphp-client 提供的http 客户端进行的封装,依赖于thinkphp6。

topphp-swoole 组件已经内置该组件

单独安装

# 运行以下命令

$ composer require topphp/topphp-consul

配置

配置文件 config/consul.php

return [

'uri' => '127.0.0.1:8500'

];

使用

获取相应客户端对象

$this->agent = App::make(Agent::class);

$this->kv = App::make(KV::class);

$this->health = App::make(Health::class);

//返回一个 `ConsulResponse` 对象,可以通过 `->json()` 获取相应json数据

$services = $this->health->service($serviceName);

$services = $this->health->service($serviceName)->json();

相关api

Catalog

Session

注意

交互输入必须使用英文半角输入法,否则会出现字符确实.

现代的PHP组件都使用语义版本方案(http://semver.org), 版本号由三个点(.)分数字组成(例如:1.13.2).第一个数字是主版本号,如果PHP组件更新破坏了向后兼容性,会提升主版本号.

第二个数字是次版本号,如果PHP组件小幅更新了功能,而且没有破坏向后兼容性,会提升次版本号.

第三个数字(即最后一个数字)是修订版本号,如果PHP组件修正了向后兼容的缺陷,会提升修订版本号.

Structure

组件结构

bin/

build/

docs/

config/

src/

tests/

vendor/

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Security

If you discover any security related issues, please email sleep@kaituocn.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值