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,18 +1,21 @@
<?php
declare(strict_types=1);
/**
use Hyperf\Cache\Driver\RedisDriver;
use Hyperf\Codec\Packer\PhpSerializerPacker;
/*
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @see https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
return [
'default' => [
'driver' => Hyperf\Cache\Driver\RedisDriver::class,
'packer' => Hyperf\Codec\Packer\PhpSerializerPacker::class,
'driver' => RedisDriver::class,
'packer' => PhpSerializerPacker::class,
'prefix' => 'c:',
'skip_cache_results' => [],
],

View File

@@ -1,44 +1,36 @@
<?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
*/
return [
'generator' => [
'amqp' => [
'consumer' => [
'namespace' => 'App\\Amqp\\Consumer',
'namespace' => 'App\Amqp\Consumer',
],
'producer' => [
'namespace' => 'App\\Amqp\\Producer',
'namespace' => 'App\Amqp\Producer',
],
],
'aspect' => [
'namespace' => 'App\\Aspect',
'namespace' => 'App\Aspect',
],
'command' => [
'namespace' => 'App\\Command',
'namespace' => 'App\Command',
],
'controller' => [
'namespace' => 'App\\Controller',
'namespace' => 'App\Controller',
],
'job' => [
'namespace' => 'App\\Job',
'namespace' => 'App\Job',
],
'listener' => [
'namespace' => 'App\\Listener',
'namespace' => 'App\Listener',
],
'middleware' => [
'namespace' => 'App\\Middleware',
'namespace' => 'App\Middleware',
],
'Process' => [
'namespace' => 'App\\Processes',
'namespace' => 'App\Processes',
],
],
];

View File

@@ -2,20 +2,11 @@
declare(strict_types=1);
use Aether\ApiExceptionHandler;
use Aether\GlobalExceptionHandler;
use Aether\RpcExceptionHandler;
use Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler;
return [
'handler' => [
'http' => [
// HttpExceptionHandler::class,
// ApiExceptionHandler::class,
GlobalExceptionHandler::class,
],
'jsonrpc-http' => [
HttpExceptionHandler::class,
RpcExceptionHandler::class,
],
],

View File

@@ -1,15 +1,18 @@
<?php
declare(strict_types=1);
/**
use Hyperf\Command\Listener\FailToHandleListener;
use Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler;
/*
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @see https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
return [
Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::class,
Hyperf\Command\Listener\FailToHandleListener::class,
ErrorExceptionHandler::class,
FailToHandleListener::class,
];

View File

@@ -1,10 +1,14 @@
<?php
declare(strict_types=1);
/**
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
/*
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @see https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
@@ -12,14 +16,14 @@ declare(strict_types=1);
return [
'default' => [
'handler' => [
'class' => Monolog\Handler\StreamHandler::class,
'class' => StreamHandler::class,
'constructor' => [
'stream' => BASE_PATH . '/runtime/logs/hyperf.log',
'level' => Monolog\Logger::DEBUG,
'level' => Logger::DEBUG,
],
],
'formatter' => [
'class' => Monolog\Formatter\LineFormatter::class,
'class' => LineFormatter::class,
'constructor' => [
'format' => null,
'dateFormat' => 'Y-m-d H:i:s',

View File

@@ -15,20 +15,6 @@ use function Hyperf\Support\env;
return [
'mode' => SWOOLE_PROCESS,
'servers' => [
// [
// 'name' => 'http',
// 'type' => Server::SERVER_HTTP,
// 'host' => '0.0.0.0',
// 'port' => 9501,
// 'sock_type' => SWOOLE_SOCK_TCP,
// 'callbacks' => [
// Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'],
// ],
// 'options' => [
// // Whether to enable request lifecycle event
// 'enable_request_lifecycle' => false,
// ],
// ],
[
'name' => 'jsonrpc-http',
'type' => Server::SERVER_HTTP,
@@ -39,7 +25,7 @@ return [
Event::ON_REQUEST => [JsonRpcHttpServer::class, 'onRequest'],
],
'settings' => [
// 'open_eof_split' => true,
'open_eof_split' => true,
'package_eof' => "\r\n",
'package_max_length' => 1024 * 1024 * 2,
],

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,
],
],
];