改名
This commit is contained in:
+10
-11
@@ -19,11 +19,19 @@ use Snowflake\Snowflake;
|
|||||||
/**
|
/**
|
||||||
* LocalService constructor.
|
* LocalService constructor.
|
||||||
* @param string $service
|
* @param string $service
|
||||||
* @param array $args
|
* @param array|null $args
|
||||||
* @param bool $async_reload
|
* @param bool $async_reload
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(public string $service, public array $args = [], public bool $async_reload = true)
|
public function __construct(public string $service, public ?array $args = [], public bool $async_reload = true)
|
||||||
{
|
{
|
||||||
|
if ($this->async_reload !== true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$event = Snowflake::app()->getEvent();
|
||||||
|
$event->on(Event::SERVER_WORKER_EXIT, function () {
|
||||||
|
Snowflake::app()->remove($this->service);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,18 +48,9 @@ use Snowflake\Snowflake;
|
|||||||
}
|
}
|
||||||
|
|
||||||
Snowflake::set($this->service, $class);
|
Snowflake::set($this->service, $class);
|
||||||
// if ($this->async_reload === true) {
|
|
||||||
// $event = Snowflake::app()->getEvent();
|
|
||||||
// $event->on(Event::SERVER_WORKER_EXIT, [$this, 'clear']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return parent::execute($handler); // TODO: Change the autogenerated stub
|
return parent::execute($handler); // TODO: Change the autogenerated stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function clear()
|
|
||||||
{
|
|
||||||
Snowflake::app()->remove($this->service);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user