Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alicfeng/service-client
一款远程调用微服务通讯的客户端,支持多种通讯协议
https://github.com/alicfeng/service-client
Last synced: 20 days ago
JSON representation
一款远程调用微服务通讯的客户端,支持多种通讯协议
- Host: GitHub
- URL: https://github.com/alicfeng/service-client
- Owner: alicfeng
- License: mit
- Created: 2021-05-19T02:18:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-11T05:32:58.000Z (over 3 years ago)
- Last Synced: 2024-04-17T00:16:45.754Z (9 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
服务客户端
一款远程调用微服务通讯的客户端
支持多种通讯协议的远程调用客户端,安装一个客户端可配置灵活调用多个服务
## 🚀 安装配置
- **`standard`**
```
composer require alicfeng/service-client -vvv
```- **`Laravel`**
```shell
php artisan vendor:publish --provider="Samego\Client\ServiceProvider\ServiceClientProvider"
```
## ✨ 支持特性
- [x] Http
- [ ] ICE
- [ ] Grpc
## ☛ 快速使用
```php
[
'success_code' => 1000,
],
// 协议驱动 HTTP
'http' => [
// 路由列表
'routes' => [
// 服务路由 服务名称.路由别名
'user.profile' => [
'uri' => '/api/user',
'method' => 'GET',
'headers' => [
],
],
],
// 服务分组 配置每组服务通用配置
'groups' => [
'user' => [
'timeout' => 60,
'base_uri' => env('SERVICE_CLIENT_USER_SERVER_BASE_URI'),
'verify' => env('SERVICE_CLIENT_USER_SERVER_VERIFY', false),
'headers' => [
],
],
],
],
];
``````php
use Samego\Client\Facades\ServiceHttpClient;// 简单请求
ServiceHttpClient::service('user.profile')->request();// 复杂请求
ServiceHttpClient::service('user.profile')->package(['name'=>'samego'])->header(['Auth'=>'token'])->uri('api/user/profile')->request();
```## ✅组件建议
1. 对于 `Http` 提供服务的建议使用 [laravel-response](https://github.com/alicfeng/laravel-response) 作为配套响应组件