Fix the path of CoroutineServerStats (#5378)

This commit is contained in:
Deeka Wong 2023-02-09 10:12:18 +08:00 committed by GitHub
parent 7885e6ba43
commit 2adfa8c482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -9,7 +9,7 @@ declare(strict_types=1);
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Server;
namespace Hyperf\Metric;
use Hyperf\Contract\Arrayable;

View File

@ -18,10 +18,10 @@ use Hyperf\Coordinator\Timer;
use Hyperf\Engine\Coroutine as Co;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Metric\Contract\MetricFactoryInterface;
use Hyperf\Metric\CoroutineServerStats;
use Hyperf\Metric\Event\MetricFactoryReady;
use Hyperf\Metric\MetricFactoryPicker;
use Hyperf\Metric\MetricSetter;
use Hyperf\Server\CoroutineServerStats;
use Hyperf\Utils\Coroutine;
use Hyperf\Utils\System;
use Psr\Container\ContainerInterface;
@ -99,7 +99,9 @@ class OnMetricFactoryReady implements ListenerInterface
if ($server instanceof SwooleServer) {
$serverStatsFactory = fn (): array => $server->stats();
}
} else {
}
if (! $serverStatsFactory) {
$serverStatsFactory = fn (): array => $this->container->get(CoroutineServerStats::class)->toArray();
}
}

View File

@ -12,8 +12,8 @@ declare(strict_types=1);
namespace Hyperf\Metric\Middleware;
use Hyperf\HttpServer\Router\Dispatched;
use Hyperf\Metric\CoroutineServerStats;
use Hyperf\Metric\Timer;
use Hyperf\Server\CoroutineServerStats;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;