mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Added NullDisableEventDispatcher
to disable event dispatcher by default. (#4852)
Co-authored-by: huangdijia <huangdijia@gmail.com>
This commit is contained in:
parent
624f0d158f
commit
c8d4d666aa
@ -48,6 +48,7 @@ composer analyse
|
||||
- [#4523](https://github.com/hyperf/hyperf/pull/4523) Support callback conditions for `Conditionable::when()` and `Conditionable::unless()`.
|
||||
- [#4663](https://github.com/hyperf/hyperf/pull/4663) Make `Hyperf\Utils\Stringable` implements `Stringable`.
|
||||
- [#4700](https://github.com/hyperf/hyperf/pull/4700) Support coroutine style server for `socketio-server`.
|
||||
- [#4852](https://github.com/hyperf/hyperf/pull/4852) Added `NullDisableEventDispatcher` to disable event dispatcher by default.
|
||||
|
||||
## Optimized
|
||||
|
||||
|
@ -18,7 +18,7 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
trait DisableEventDispatcher
|
||||
{
|
||||
public function addDisableDispatcherOption()
|
||||
public function addDisableDispatcherOption(): void
|
||||
{
|
||||
$this->addOption('disable-event-dispatcher', null, InputOption::VALUE_NONE, 'Whether disable event dispatcher.');
|
||||
}
|
||||
|
25
src/command/src/NullDisableEventDispatcher.php
Normal file
25
src/command/src/NullDisableEventDispatcher.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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
|
||||
*/
|
||||
namespace Hyperf\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
trait NullDisableEventDispatcher
|
||||
{
|
||||
public function addDisableDispatcherOption(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function disableDispatcher(InputInterface $input)
|
||||
{
|
||||
}
|
||||
}
|
@ -103,7 +103,7 @@ class MetricFactory implements MetricFactoryInterface
|
||||
$port = $this->config->get("metric.metric.{$this->name}.scrape_port");
|
||||
$path = $this->config->get("metric.metric.{$this->name}.scrape_path");
|
||||
$renderer = new RenderTextFormat();
|
||||
$server = new Server($host, (int) $port, false);
|
||||
$server = new Server($host, (int) $port, false, true);
|
||||
Coroutine::create(static function () use ($server) {
|
||||
CoordinatorManager::until(Coord::WORKER_EXIT)->yield();
|
||||
$server->shutdown();
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Watcher\Command;
|
||||
|
||||
use Hyperf\Command\Command;
|
||||
use Hyperf\Command\NullDisableEventDispatcher;
|
||||
use Hyperf\Watcher\Option;
|
||||
use Hyperf\Watcher\Watcher;
|
||||
use Psr\Container\ContainerInterface;
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class WatchCommand extends Command
|
||||
{
|
||||
use NullDisableEventDispatcher;
|
||||
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('server:watch');
|
||||
|
Loading…
Reference in New Issue
Block a user