This commit is contained in:
Aether
2025-09-26 15:36:09 +08:00
parent 0c7142ad46
commit f3a672b5c9
6 changed files with 295 additions and 46 deletions

View File

@@ -10,7 +10,7 @@ return [
'port' => env('NACOS_PORT', 8848),
// 'username' => env('NACOS_USERNAME', 'nacos'),
// 'password' => env('NACOS_PASSWORD', 'nacos'),
'namespace' => env('NACOS_NAMESPACE', 'dev'),
'namespace' => env('NACOS_NAMESPACE_ID', 'dev'),
'timeout' => 5.0,
],
];

View File

@@ -1,6 +1,7 @@
<?php
use MicroService\Contract\DataServiceInterface;
declare(strict_types=1);
use function Hyperf\Support\env;
return [
@@ -8,39 +9,14 @@ return [
'discovery' => true,
'register' => true,
],
'consumers' => [
// 数据服务消费者配置
[
'name' => 'DataService',
'service' => DataServiceInterface::class,
'registry' => [
'protocol' => 'nacos',
'address' => 'http://192.168.28.199:8848/',
],
'protocol' => 'jsonrpc-http',
'options' => [
'timeout' => 0.5,
],
],
],
'providers' => [
[
'id' => 'hyperf-gateway',
'service' => 'hyperf-gateway',
'protocol' => 'jsonrpc-http',
'load_balancer' => 'random',
'registry' => [
'protocol' => 'nacos',
'address' => 'http://192.168.28.199:8848',
],
],
],
'consumers' => [],
'providers' => [],
'drivers' => [
'nacos' => [
// nacos server url like https://nacos.hyperf.io, Priority is higher than host:port
// 'url' => '',
// The nacos host info
'host' => env('NACOS_HOST', '192.168.28.199'),
'host' => env('NACOS_HOST', '127.0.0.1'),
'port' => env('NACOS_PORT', 8848),
// The nacos account info
// 'username' => null,
@@ -48,8 +24,8 @@ return [
'guzzle' => [
'config' => null,
],
'group_name' => env('NACOS_GROUP', 'api'),
'namespace_id' => env('NACOS_NAMESPACE_ID', 'dev'),
'group_name' => env('NACOS_GROUP', 'DEFAULT_GROUP'),
'namespace_id' => env('NACOS_NAMESPACE', 'dev'),
'heartbeat' => 5,
],
],