This commit is contained in:
as2252258@163.com
2021-08-29 04:06:49 +08:00
parent 9da50baed0
commit 133ca2c273
21 changed files with 356 additions and 495 deletions
+12 -13
View File
@@ -24,15 +24,8 @@ use Server\Events\OnWorkerExit;
* @param bool $async_reload
* @throws Exception
*/
public function __construct(public string $service, public ?array $args = [], public bool $async_reload = true)
public function __construct(string $service, ?array $args = [], bool $async_reload = true)
{
if ($this->async_reload !== true) {
return;
}
$pro = di(EventProvider::class);
$pro->on(OnWorkerExit::class, function () {
di(\Kiri\Di\LocalService::class)->remove($this->service);
},0);
}
@@ -42,14 +35,20 @@ use Server\Events\OnWorkerExit;
* @return bool
* @throws Exception
*/
public function execute(mixed $class, mixed $method = null): bool
public static function execute(mixed $params, mixed $class, mixed $method = null): bool
{
$class = ['class' => $class];
if (!empty($this->args)) {
$class = array_merge($class, $this->args);
if (!empty($params->args)) {
$class = array_merge($class, $params->args);
}
Kiri::set($this->service, $class);
return true; // TODO: Change the autogenerated stub
if ($params->async_reload !== true) {
$pro = di(EventProvider::class);
$pro->on(OnWorkerExit::class, function () use ($params) {
di(\Kiri\Di\LocalService::class)->remove($params->service);
},0);
}
Kiri::set($params->service, $class);
return true;
}
}