改名
This commit is contained in:
+37
-35
@@ -6,8 +6,10 @@ namespace Snowflake\Process;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Snowflake\Application;
|
use Snowflake\Application;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,47 +19,47 @@ use Snowflake\Snowflake;
|
|||||||
abstract class Process extends \Swoole\Process implements SProcess
|
abstract class Process extends \Swoole\Process implements SProcess
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var Application $application */
|
/** @var Application $application */
|
||||||
protected Application $application;
|
protected Application $application;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process constructor.
|
* Process constructor.
|
||||||
* @param $application
|
* @param $application
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param bool $enable_coroutine
|
* @param bool $enable_coroutine
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($application, $name, $enable_coroutine = true)
|
public function __construct($application, $name, $enable_coroutine = true)
|
||||||
{
|
{
|
||||||
parent::__construct([$this, '_load'], false, 1, $enable_coroutine);
|
parent::__construct([$this, '_load'], false, 1, $enable_coroutine);
|
||||||
$this->application = $application;
|
$this->application = $application;
|
||||||
Snowflake::setWorkerId($this->pid);
|
Snowflake::setWorkerId($this->pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Process $process
|
* @param Process $process
|
||||||
* @throws \Snowflake\Exception\ComponentException
|
* @throws ComponentException
|
||||||
*/
|
*/
|
||||||
public function _load(Process $process)
|
public function _load(Process $process)
|
||||||
{
|
{
|
||||||
putenv('environmental=' . Snowflake::PROCESS);
|
putenv('environmental=' . Snowflake::PROCESS);
|
||||||
|
|
||||||
fire(Event::SERVER_WORKER_START);
|
fire(Event::SERVER_WORKER_START);
|
||||||
if (Snowflake::isLinux()) {
|
if (Snowflake::isLinux()) {
|
||||||
$this->name($this->getPrefix());
|
$this->name($this->getPrefix());
|
||||||
}
|
}
|
||||||
$this->onHandler($process);
|
$this->onHandler($process);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getPrefix(): string
|
#[Pure] private function getPrefix(): string
|
||||||
{
|
{
|
||||||
return ucfirst(rtrim(Snowflake::app()->id, ':') . ': ' . get_called_class());
|
return Snowflake::app()->id . get_called_class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user