This commit is contained in:
Aether
2025-09-26 10:41:43 +08:00
parent 26ee79b951
commit 0c7142ad46
14 changed files with 157 additions and 427 deletions

View File

@@ -1,62 +1,56 @@
<?php
declare(strict_types=1);
use MicroService\Contract\DataServiceInterface;
use function Hyperf\Support\env;
return [
'enable' => true,
'driver' => 'nacos',
'enable' => [
'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',
],
],
],
'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', '127.0.0.1'),
'host' => env('NACOS_HOST', '192.168.28.199'),
'port' => env('NACOS_PORT', 8848),
// The nacos account info
'username' => null,
'password' => null,
// 'username' => null,
// 'password' => null,
'guzzle' => [
'config' => null,
],
'group_name' => 'api',
'namespace_id' => env('NACOS_NAMESPACE', 'dev'),
'group_name' => env('NACOS_GROUP', 'api'),
'namespace_id' => env('NACOS_NAMESPACE_ID', 'dev'),
'heartbeat' => 5,
],
],
'registries' => [
[
'name' => 'DataCampus',
'host' => env('NACOS_HOST', '192.168.28.199'),
'port' => env('NACOS_PORT', 8848),
// 'username' => env('NACOS_USERNAME', 'nacos'),
// 'password' => env('NACOS_PASSWORD', 'nacos'),
'namespace' => env('NACOS_NAMESPACE', 'e42b853c-5195-478b-b5e3-6d49f6a45053'),
'group_name' => env('NACOS_GROUP', 'DEFAULT_GROUP'),
'service_name' => 'DataCampus',
'metadata' => [
'protocol' => 'jsonrpc-http',
'server' => 'jsonrpc-http',
],
'heartbeat' => 5,
'heartbeat_timeout' => 15,
],
[
'name' => 'DataTeacherService',
'host' => env('NACOS_HOST', '192.168.28.199'),
'port' => env('NACOS_PORT', 8848),
// 'username' => env('NACOS_USERNAME', 'nacos'),
// 'password' => env('NACOS_PASSWORD', 'nacos'),
'namespace' => env('NACOS_NAMESPACE', 'e42b853c-5195-478b-b5e3-6d49f6a45053'),
'group_name' => env('NACOS_GROUP', 'DEFAULT_GROUP'),
'service_name' => 'DataTeacherService',
'metadata' => [
'protocol' => 'jsonrpc-http',
'server' => 'jsonrpc-http',
],
'heartbeat' => 5,
'heartbeat_timeout' => 15,
],
],
];