Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alicfeng/service-client

一款远程调用微服务通讯的客户端,支持多种通讯协议
https://github.com/alicfeng/service-client

Last synced: 20 days ago
JSON representation

一款远程调用微服务通讯的客户端,支持多种通讯协议

Awesome Lists containing this project

README

        



服务客户端



一款远程调用微服务通讯的客户端


支持多种通讯协议的远程调用客户端,安装一个客户端可配置灵活调用多个服务




Build Status


Latest Stable Version


Total Downloads


License

## 🚀 安装配置

- **`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) 作为配套响应组件