This commit is contained in:
63
config/autoload/services.php
Normal file
63
config/autoload/services.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
use App\JsonRpc\EasyAppServiceInterface;
|
||||
use App\JsonRpc\InventoryServiceInterface;
|
||||
use App\JsonRpc\UserAuthServiceInterface;
|
||||
use function Hyperf\Support\value;
|
||||
|
||||
return [
|
||||
'consumers' => value(function () {
|
||||
$consumers = [];
|
||||
$services = [
|
||||
'UserAuthService' => UserAuthServiceInterface::class,
|
||||
'EasyAppService' => EasyAppServiceInterface::class,
|
||||
'InventoryService' => InventoryServiceInterface::class,
|
||||
];
|
||||
foreach ($services as $name => $interface) {
|
||||
$consumers[] = [
|
||||
'name' => $name,
|
||||
'service' => $interface,
|
||||
'protocol' => 'jsonrpc-http',
|
||||
'load_balancer' => 'random',
|
||||
'registry' => [
|
||||
'protocol' => 'nacos',
|
||||
'address' => 'http://127.0.0.1:8848',
|
||||
],
|
||||
'options' => [
|
||||
'connect_timeout' => 5.0,
|
||||
'recv_timeout' => 5.0,
|
||||
'settings' => [
|
||||
// 开启连接池
|
||||
'open_connection_pool' => true,
|
||||
],
|
||||
// 重试次数,默认值为 2,收包超时不进行重试。暂只支持 JsonRpcPoolTransporter
|
||||
'retry_count' => 2,
|
||||
// 重试间隔,毫秒
|
||||
'retry_interval' => 100,
|
||||
// 使用多路复用 RPC 时的心跳间隔,null 为不触发心跳
|
||||
'heartbeat' => 30,
|
||||
'pool' => [
|
||||
'min_connections' => 1,
|
||||
'max_connections' => 100,
|
||||
'connect_timeout' => 10.0,
|
||||
'wait_timeout' => 3.0,
|
||||
'heartbeat' => 30,
|
||||
'max_idle_time' => 60.0,
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
return $consumers;
|
||||
}),
|
||||
];
|
Reference in New Issue
Block a user