crayoon / hyperf-grpc-client
hyperf grpc client
Installs: 1 136
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=8.0
- hyperf/di: 3.0.*
- hyperf/grpc-client: ^3.0
- hyperf/load-balancer: ^3.0
- hyperf/service-governance: ^3.0
- hyperf/service-governance-consul: ^3.0
- hyperf/service-governance-nacos: ^3.0
- hyperf/tracer: ^3.0
- jonahgeorge/jaeger-client-php: ^1.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2024-12-08 11:41:36 UTC
README
hyperf grpc 客户端,支持服务发现、负载均衡、Dtm通过服务发现、服务链路跟踪等
请先阅读hyperf文档 grpc服务一节 https://hyperf.wiki/3.0/#/zh-cn/grpc
引用
composer require crayoon/hyperf-grpc-client
生成配置文件
// 若有引用 crayoon/hyperf-grpc 请使用crayoon/hyperf-grpc发布配置
// php bin/hyperf.php vendor:publish crayoon/hyperf-grpc
// 否则
php bin/hyperf.php vendor:publish crayoon/hyperf-grpc-client
使用
// 客户端 继承 \Crayoon\HyperfGrpcClient\BaseGrpcClient 即可 class GoodsClient extends \Crayoon\HyperfGrpcClient\BaseGrpcClient { ... }
DTM
兼容dtm通过服务发现负载调用服务
请先阅读hyperf文档 DTM一节 https://hyperf.wiki/3.0/#/zh-cn/distributed-transaction
// 引入
composer require dtm/dtm-client
// 发布配置
php bin/hyperf.php vendor:publish dtm/dtm-client
修改 config/dependencies.php
return [ // 加入下面两个映射 \DtmClient\Api\GrpcApi::class => \Crayoon\HyperfGrpcClient\DTM\GrpcApi::class, \Crayoon\HyperfGrpcClient\GrpcClientManager::class => \Crayoon\HyperfGrpcClient\DTM\GrpcClientManagerWithDtmClient::class, ];