This commit is contained in:
xl
2024-08-29 17:01:07 +08:00
parent b14b18040b
commit 917e82064a
8 changed files with 34 additions and 75 deletions
+3 -4
View File
@@ -63,16 +63,15 @@ class OnRequest implements OnRequestInterface
* @param DataGrip $dataGrip
* @throws
*/
public function __construct(public ResponseInterface $response, public ContainerInterface $container,
public DataGrip $dataGrip)
public function __construct(public ResponseInterface $response, DataGrip $dataGrip)
{
$this->responseEmitter = $this->response->emmit;
$exception = \config('exception.http');
if (!in_array(ExceptionHandlerInterface::class, class_implements($exception))) {
$exception = ExceptionHandlerDispatcher::class;
}
$this->exception = $this->container->get($exception);
$this->router = $this->dataGrip->get(ROUTER_TYPE_HTTP);
$this->exception = \Kiri::getDi()->get($exception);
$this->router = $dataGrip->get(ROUTER_TYPE_HTTP);
}
+5 -12
View File
@@ -26,14 +26,6 @@ use function config;
class OnServerWorker extends Kiri\Server\Abstracts\Server
{
/**
* @var EventDispatch
*/
#[Container(EventDispatch::class)]
public EventDispatch $dispatch;
/**
* @return void
*/
@@ -68,13 +60,14 @@ class OnServerWorker extends Kiri\Server\Abstracts\Server
*/
public function onWorkerStart(Server $server, int $workerId): void
{
$this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
$dispatch = Kiri::getDi()->get(EventDispatch::class);
$dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
if ($workerId < $server->setting['worker_num']) {
$this->dispatch->dispatch(new OnWorkerStart($server, $workerId));
$dispatch->dispatch(new OnWorkerStart($server, $workerId));
} else {
$this->dispatch->dispatch(new OnTaskerStart($server, $workerId));
$dispatch->dispatch(new OnTaskerStart($server, $workerId));
}
$this->dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
$dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
}