diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index dea7253c..20644358 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -3,7 +3,7 @@ namespace PHPSTORM_META { // Reflect - use Snowflake\Di\Container; + use Kiri\Di\Container; override(Container::get(0), map('@')); override(Container::newObject(0), map('@')); diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index c22fd1ee..de76411e 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -7,7 +7,7 @@ namespace Annotation; use DirectoryIterator; use Exception; use ReflectionException; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** * Class Annotation diff --git a/Annotation/Aspect.php b/Annotation/Aspect.php index 8e42d7bd..0bbafdf9 100644 --- a/Annotation/Aspect.php +++ b/Annotation/Aspect.php @@ -5,9 +5,9 @@ namespace Annotation; use Exception; -use Snowflake\Aop; -use Snowflake\IAspect; -use Snowflake\Snowflake; +use Kiri\Aop; +use Kiri\IAspect; +use Kiri\Kiri; defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implement '); diff --git a/Annotation/Asynchronous.php b/Annotation/Asynchronous.php index 428e1eca..3b17b9da 100644 --- a/Annotation/Asynchronous.php +++ b/Annotation/Asynchronous.php @@ -6,7 +6,7 @@ namespace Annotation; use Exception; use HttpServer\IInterface\Task; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -36,7 +36,7 @@ use Snowflake\Snowflake; */ public function execute(mixed $class, mixed $method = null): bool { - $async = Snowflake::app()->getAsync(); + $async = Kiri::app()->getAsync(); $async->addAsync($this->name, $class); return true; } diff --git a/Annotation/Event.php b/Annotation/Event.php index def3c05e..2f9b4698 100644 --- a/Annotation/Event.php +++ b/Annotation/Event.php @@ -5,9 +5,9 @@ namespace Annotation; use Exception; -use Snowflake\Exception\ComponentException; -use Snowflake\Snowflake; -use Snowflake\Event as SEvent; +use Kiri\Exception\ComponentException; +use Kiri\Kiri; +use Kiri\Event as SEvent; /** diff --git a/Annotation/Inject.php b/Annotation/Inject.php index 7e990ce4..9ff067d2 100644 --- a/Annotation/Inject.php +++ b/Annotation/Inject.php @@ -8,8 +8,8 @@ use Exception; use HttpServer\Http\Context; use ReflectionException; use ReflectionProperty; -use Snowflake\Core\Str; -use Snowflake\Snowflake; +use Kiri\Core\Str; +use Kiri\Kiri; /** * Class Inject @@ -81,7 +81,7 @@ use Snowflake\Snowflake; return $method; } if (is_object($class)) $class = $class::class; - $method = Snowflake::getDi()->getClassReflectionProperty($class, $method); + $method = Kiri::getDi()->getClassReflectionProperty($class, $method); if (!$method || $method->isStatic()) { return false; } @@ -99,9 +99,9 @@ use Snowflake\Snowflake; return Context::getContext($this->value); } if (class_exists($this->value)) { - return Snowflake::getDi()->get($this->value, $this->args); - } else if (Snowflake::app()->has($this->value)) { - return Snowflake::app()->get($this->value); + return Kiri::getDi()->get($this->value, $this->args); + } else if (Kiri::app()->has($this->value)) { + return Kiri::app()->get($this->value); } else { return $this->value; } diff --git a/Annotation/Kafka.php b/Annotation/Kafka.php index 355b0b59..634ab771 100644 --- a/Annotation/Kafka.php +++ b/Annotation/Kafka.php @@ -7,7 +7,7 @@ namespace Annotation; use Exception; use Kafka\ConsumerInterface; use Kafka\KafkaProvider; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class Kafka @@ -39,7 +39,7 @@ use Snowflake\Snowflake; } /** @var KafkaProvider $container */ - $container = Snowflake::getDi()->get(KafkaProvider::class); + $container = Kiri::getDi()->get(KafkaProvider::class); $container->addConsumer($this->topic, $class); return true; diff --git a/Annotation/Loader.php b/Annotation/Loader.php index b87a0bf3..feae6c74 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -8,8 +8,8 @@ use DirectoryIterator; use Exception; use ReflectionClass; use ReflectionException; -use Snowflake\Abstracts\BaseObject; -use Snowflake\Snowflake; +use Kiri\Abstracts\BaseObject; +use Kiri\Kiri; use Throwable; @@ -51,7 +51,7 @@ class Loader extends BaseObject */ public function getProperty(string $class, string $property = ''): \ReflectionProperty|array|null { - return Snowflake::getDi()->getClassReflectionProperty($class, $property); + return Kiri::getDi()->getClassReflectionProperty($class, $property); } @@ -64,7 +64,7 @@ class Loader extends BaseObject */ public function injectProperty(string $class, object $handler): static { - $di = Snowflake::getDi(); + $di = Kiri::getDi(); $reflect = $di->getReflect($class); @@ -151,7 +151,7 @@ class Loader extends BaseObject */ private function getReflect(DirectoryIterator $path, string $namespace): ?ReflectionClass { - return Snowflake::getDi()->getReflect($this->explodeFileName($path, $namespace)); + return Kiri::getDi()->getReflect($this->explodeFileName($path, $namespace)); } diff --git a/Annotation/LocalService.php b/Annotation/LocalService.php index e1689fb3..35dd3c86 100644 --- a/Annotation/LocalService.php +++ b/Annotation/LocalService.php @@ -5,8 +5,8 @@ namespace Annotation; use Exception; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Kiri; /** * Class LocalService @@ -29,7 +29,7 @@ use Snowflake\Snowflake; return; } Event::on(Event::SERVER_WORKER_EXIT, function () { - Snowflake::app()->remove($this->service); + Kiri::app()->remove($this->service); }); } @@ -47,7 +47,7 @@ use Snowflake\Snowflake; $class = array_merge($class, $this->args); } - Snowflake::set($this->service, $class); + Kiri::set($this->service, $class); return true; // TODO: Change the autogenerated stub } diff --git a/Annotation/Model/Get.php b/Annotation/Model/Get.php index 77592126..a77b7bd7 100644 --- a/Annotation/Model/Get.php +++ b/Annotation/Model/Get.php @@ -6,7 +6,7 @@ namespace Annotation\Model; use Attribute; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -34,7 +34,7 @@ use Snowflake\Snowflake; */ public function execute(mixed $class, mixed $method = null): bool { - $annotation = Snowflake::getAnnotation(); + $annotation = Kiri::getAnnotation(); $annotation->addGets($class::class, $this->name, $method); return true; } diff --git a/Annotation/Model/Relation.php b/Annotation/Model/Relation.php index 0ae61631..b6174596 100644 --- a/Annotation/Model/Relation.php +++ b/Annotation/Model/Relation.php @@ -8,7 +8,7 @@ use Annotation\Attribute; use Database\ActiveRecord; use Exception; use JetBrains\PhpStorm\Pure; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -36,7 +36,7 @@ use Snowflake\Snowflake; */ public function execute(mixed $class, mixed $method = null): bool { - $annotation = Snowflake::getAnnotation(); + $annotation = Kiri::getAnnotation(); $annotation->addRelate($class::class, $this->name, $method); return true; } diff --git a/Annotation/Model/Set.php b/Annotation/Model/Set.php index bdb3554c..60044e61 100644 --- a/Annotation/Model/Set.php +++ b/Annotation/Model/Set.php @@ -7,7 +7,7 @@ namespace Annotation\Model; use Annotation\Attribute; use Database\ActiveRecord; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; #[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute { @@ -30,7 +30,7 @@ use Snowflake\Snowflake; */ public function execute(mixed $class, mixed $method = null): bool { - $annotation = Snowflake::getAnnotation(); + $annotation = Kiri::getAnnotation(); $annotation->addSets($class::class, $this->name, $method); return true; } diff --git a/Annotation/Route/Filter.php b/Annotation/Route/Filter.php index 63fe7269..489dc26f 100644 --- a/Annotation/Route/Filter.php +++ b/Annotation/Route/Filter.php @@ -8,9 +8,9 @@ use Annotation\Attribute; use Exception; use HttpServer\HttpFilter; use ReflectionException; -use Snowflake\Exception\ComponentException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\ComponentException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** * Class Filter diff --git a/Annotation/Route/Middleware.php b/Annotation/Route/Middleware.php index cf9101e1..fb3f48c3 100644 --- a/Annotation/Route/Middleware.php +++ b/Annotation/Route/Middleware.php @@ -7,8 +7,8 @@ namespace Annotation\Route; use Annotation\Attribute; use HttpServer\Route\MiddlewareManager; use ReflectionException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use HttpServer\IInterface\Middleware as IMiddleware; /** @@ -51,7 +51,7 @@ use HttpServer\IInterface\Middleware as IMiddleware; */ public function execute(mixed $class, mixed $method = null): static { - $middleware = Snowflake::getDi()->get(MiddlewareManager::class); + $middleware = Kiri::getDi()->get(MiddlewareManager::class); $middleware->addMiddlewares($class, $method, $this->middleware); return $this; } diff --git a/Annotation/Route/Route.php b/Annotation/Route/Route.php index f6e2cc1d..73594ef0 100644 --- a/Annotation/Route/Route.php +++ b/Annotation/Route/Route.php @@ -7,7 +7,7 @@ namespace Annotation\Route; use Annotation\Attribute; use Exception; use HttpServer\Route\Router; -use Snowflake\Snowflake; +use Kiri\Kiri; #[\Attribute(\Attribute::TARGET_METHOD)] class Route extends Attribute { @@ -36,7 +36,7 @@ use Snowflake\Snowflake; public function execute(mixed $class, mixed $method = null): Router { // TODO: Implement setHandler() method. - $router = Snowflake::app()->getRouter(); + $router = Kiri::app()->getRouter(); $router->addRoute($this->uri, [$class, $method], $this->method); return $router; } diff --git a/Annotation/Route/RpcProducer.php b/Annotation/Route/RpcProducer.php index 5cb01b9f..cf0bfd82 100644 --- a/Annotation/Route/RpcProducer.php +++ b/Annotation/Route/RpcProducer.php @@ -10,7 +10,7 @@ use HttpServer\Http\Request; use HttpServer\Route\Router; use JetBrains\PhpStorm\Pure; use Rpc\Actuator; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -44,7 +44,7 @@ use Snowflake\Snowflake; public function execute(mixed $class, mixed $method = null): Router { // TODO: Implement setHandler() method. - $router = Snowflake::app()->getRouter(); + $router = Kiri::app()->getRouter(); $cmd = $this->cmd; $callback = function (Actuator $actuator) use ($cmd, $class, $method) { $actuator->addListener($cmd, $class::class . '@' . $method); diff --git a/Annotation/Route/Socket.php b/Annotation/Route/Socket.php index 629ac1c9..6d34a7e8 100644 --- a/Annotation/Route/Socket.php +++ b/Annotation/Route/Socket.php @@ -7,7 +7,7 @@ namespace Annotation\Route; use Annotation\Attribute; use Exception; use HttpServer\Route\Router; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class Socket @@ -40,7 +40,7 @@ use Snowflake\Snowflake; public function execute(mixed $class, mixed $method = null): Router { // TODO: Implement setHandler() method. - $router = Snowflake::app()->getRouter(); + $router = Kiri::app()->getRouter(); $path = $this->event . '::' . (is_null($this->uri) ? 'event' : $this->uri); diff --git a/Annotation/Rpc/Consumer.php b/Annotation/Rpc/Consumer.php index 446c3084..6077af03 100644 --- a/Annotation/Rpc/Consumer.php +++ b/Annotation/Rpc/Consumer.php @@ -6,7 +6,7 @@ namespace Annotation\Rpc; use Annotation\Attribute; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -35,7 +35,7 @@ use Snowflake\Snowflake; */ public function execute(mixed $class, mixed $method = ''): bool { - $rpc = Snowflake::app()->getRpc(); + $rpc = Kiri::app()->getRpc(); $rpc->addConsumer($this->cmd, [$class, $method]); return true; // TODO: Change the autogenerated stub } diff --git a/Annotation/Rpc/RpcClient.php b/Annotation/Rpc/RpcClient.php index 297078ed..cebec17c 100644 --- a/Annotation/Rpc/RpcClient.php +++ b/Annotation/Rpc/RpcClient.php @@ -6,7 +6,7 @@ namespace Annotation\Rpc; use Annotation\Attribute; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -45,7 +45,7 @@ use Snowflake\Snowflake; */ public function execute(mixed $class, mixed $method = ''): bool { - $rpc = Snowflake::app()->getRpc(); + $rpc = Kiri::app()->getRpc(); $rpc->addProducer($this->cmd, [$class, $method], $this->config); return true; diff --git a/Console/AbstractConsole.php b/Console/AbstractConsole.php index 22dc62df..7c4a744f 100644 --- a/Console/AbstractConsole.php +++ b/Console/AbstractConsole.php @@ -5,10 +5,10 @@ namespace Console; use Exception; -use Snowflake\Abstracts\Component; -use Snowflake\Abstracts\Input; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Abstracts\Input; +use Kiri\Event; +use Kiri\Kiri; /** * Class AbstractConsole @@ -36,7 +36,7 @@ abstract class AbstractConsole extends Component public function __construct(array $config = []) { $this->_config = $config; - $this->signCommand(Snowflake::createObject(DefaultCommand::class)); + $this->signCommand(Kiri::createObject(DefaultCommand::class)); parent::__construct($config); } @@ -117,7 +117,7 @@ abstract class AbstractConsole extends Component return; } foreach ($kernel as $command) { - $this->signCommand(Snowflake::createObject($command)); + $this->signCommand(Kiri::createObject($command)); } } diff --git a/Console/Command.php b/Console/Command.php index b4ab40cb..b9ddf138 100644 --- a/Console/Command.php +++ b/Console/Command.php @@ -4,11 +4,11 @@ declare(strict_types=1); namespace Console; use ReflectionException; -use Snowflake\Abstracts\BaseObject; -use Snowflake\Abstracts\TraitApplication; -use Snowflake\Exception\ComponentException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\BaseObject; +use Kiri\Abstracts\TraitApplication; +use Kiri\Exception\ComponentException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** * Class Command @@ -66,7 +66,7 @@ abstract class Command extends BaseObject implements CommandInterface */ private function has($name): bool { - return Snowflake::app()->has($name); + return Kiri::app()->has($name); } @@ -79,7 +79,7 @@ abstract class Command extends BaseObject implements CommandInterface */ private function get($name): mixed { - return Snowflake::app()->get($name); + return Kiri::app()->get($name); } diff --git a/Console/CommandInterface.php b/Console/CommandInterface.php index 764591a7..65d0ea64 100644 --- a/Console/CommandInterface.php +++ b/Console/CommandInterface.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Console; -use Snowflake\Abstracts\Input; +use Kiri\Abstracts\Input; /** * Interface CommandInterface diff --git a/Console/Console.php b/Console/Console.php index 77fa3a83..0e00a5a2 100644 --- a/Console/Console.php +++ b/Console/Console.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Console; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class Console @@ -21,7 +21,7 @@ class Console extends AbstractConsole public function register($class) { if (is_string($class) || is_callable($class, true)) { - $class = Snowflake::createObject($class); + $class = Kiri::createObject($class); } $this->signCommand($class); } diff --git a/Console/ConsoleProviders.php b/Console/ConsoleProviders.php index 3ab359bc..6663f662 100644 --- a/Console/ConsoleProviders.php +++ b/Console/ConsoleProviders.php @@ -4,8 +4,8 @@ namespace Console; use Exception; -use Snowflake\Abstracts\Providers; -use Snowflake\Application; +use Kiri\Abstracts\Providers; +use Kiri\Application; /** * Class ConsoleProviders diff --git a/Console/DefaultCommand.php b/Console/DefaultCommand.php index adf1cb71..6dde37ea 100644 --- a/Console/DefaultCommand.php +++ b/Console/DefaultCommand.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Console; -use Snowflake\Abstracts\Input; +use Kiri\Abstracts\Input; /** * Class DefaultCommand diff --git a/Console/ICommand.php b/Console/ICommand.php index 084ce932..9219b431 100644 --- a/Console/ICommand.php +++ b/Console/ICommand.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Console; -use Snowflake\Abstracts\Input; +use Kiri\Abstracts\Input; interface ICommand { diff --git a/Database/ActiveQuery.php b/Database/ActiveQuery.php index f415d656..5de55661 100644 --- a/Database/ActiveQuery.php +++ b/Database/ActiveQuery.php @@ -11,7 +11,7 @@ namespace Database; use Database\Traits\QueryTrait; use Exception; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** * Class ActiveQuery diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index 9eaebc6c..a75e082e 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -14,8 +14,8 @@ use Database\Base\BaseActiveRecord; use Database\Traits\HasBase; use Exception; use ReflectionException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; defined('SAVE_FAIL') or define('SAVE_FAIL', 3227); defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.'); @@ -115,7 +115,7 @@ class ActiveRecord extends BaseActiveRecord */ public static function findOrCreate(array $condition, array $attributes = []): bool|static { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); /** @var static $select */ $select = static::find()->where($condition)->first(); @@ -142,7 +142,7 @@ class ActiveRecord extends BaseActiveRecord */ public static function createOrUpdate(array $condition, array $attributes = []): bool|static { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); if (empty($attributes)) { return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql'); } @@ -200,7 +200,7 @@ class ActiveRecord extends BaseActiveRecord public static function inserts(array $data): bool { /** @var static $class */ - $class = Snowflake::createObject(['class' => static::class]); + $class = Kiri::createObject(['class' => static::class]); if (empty($data)) { return $class->addError('Insert data empty.', 'mysql'); } @@ -288,7 +288,7 @@ class ActiveRecord extends BaseActiveRecord { $data = $this->_attributes; - $lists = Snowflake::getAnnotation()->getGets(static::class); + $lists = Kiri::getAnnotation()->getGets(static::class); foreach ($lists as $key => $item) { $data[$key] = $this->{$item}($data[$key] ?? null); } diff --git a/Database/Base/AbstractCollection.php b/Database/Base/AbstractCollection.php index 4d2a1219..7f4e7f71 100644 --- a/Database/Base/AbstractCollection.php +++ b/Database/Base/AbstractCollection.php @@ -15,8 +15,8 @@ use Database\ActiveQuery; use Database\ActiveRecord; use Exception; use JetBrains\PhpStorm\Pure; -use Snowflake\Abstracts\Component; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Kiri; use Traversable; /** diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index b2642081..7d5cde3d 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -26,20 +26,20 @@ use Database\Traits\HasBase; use Exception; use JetBrains\PhpStorm\Pure; use ReflectionException; -use Snowflake\Abstracts\Component; -use Snowflake\Abstracts\Config; -use Snowflake\Abstracts\TraitApplication; -use Snowflake\Application; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Abstracts\Config; +use Kiri\Abstracts\TraitApplication; +use Kiri\Application; +use Kiri\Events\EventDispatch; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use validator\Validator; /** * Class BOrm * - * @package Snowflake\Abstracts + * @package Kiri\Abstracts * * @property bool $isCreate * @method rules() @@ -114,7 +114,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ #[Pure] protected function getContainer(): Application { - return Snowflake::app(); + return Kiri::app(); } @@ -125,7 +125,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ protected function getEventDispatch(): EventDispatch { - return Snowflake::getDi()->get(EventDispatch::class); + return Kiri::getDi()->get(EventDispatch::class); } @@ -176,7 +176,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ public function init() { - $an = Snowflake::app()->getAnnotation(); + $an = Kiri::app()->getAnnotation(); $an->injectProperty($this); } @@ -216,7 +216,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ public function getLastError(): mixed { - return Snowflake::app()->getLogger()->getLastError('mysql'); + return Kiri::app()->getLogger()->getLastError('mysql'); } @@ -705,7 +705,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ public function getRelate($name): null|array|string { - return Snowflake::getAnnotation()->getRelateMethods(static::class, $name); + return Kiri::getAnnotation()->getRelateMethods(static::class, $name); } @@ -811,7 +811,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ protected function _get_annotation(string $name = null, string $method = self::GET): ?string { - $annotation = Snowflake::app()->getAnnotation(); + $annotation = Kiri::app()->getAnnotation(); if ($method == static::SET) { return $annotation->getSetMethodName(static::class, $name); } @@ -1032,7 +1032,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ public static function setDatabaseConnect($dbName): Connection { - return Snowflake::app()->db->get(static::$connection = $dbName); + return Kiri::app()->db->get(static::$connection = $dbName); } diff --git a/Database/Command.php b/Database/Command.php index e47e881c..83a1fb4d 100644 --- a/Database/Command.php +++ b/Database/Command.php @@ -13,8 +13,8 @@ namespace Database; use Exception; use PDO; use PDOStatement; -use Snowflake\Abstracts\Component; -use Snowflake\Core\Json; +use Kiri\Abstracts\Component; +use Kiri\Core\Json; /** * Class Command diff --git a/Database/Condition/Condition.php b/Database/Condition/Condition.php index ac501f29..a331a4e0 100644 --- a/Database/Condition/Condition.php +++ b/Database/Condition/Condition.php @@ -5,8 +5,8 @@ namespace Database\Condition; use JetBrains\PhpStorm\Pure; -use Snowflake\Abstracts\BaseObject; -use Snowflake\Core\Str; +use Kiri\Abstracts\BaseObject; +use Kiri\Core\Str; /** * Class Condition diff --git a/Database/Condition/LLikeCondition.php b/Database/Condition/LLikeCondition.php index 635781f6..091ee3b5 100644 --- a/Database/Condition/LLikeCondition.php +++ b/Database/Condition/LLikeCondition.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace Database\Condition; -use Snowflake\Core\Str; +use Kiri\Core\Str; /** * Class LLikeCondition diff --git a/Database/Condition/LikeCondition.php b/Database/Condition/LikeCondition.php index 379b7fa6..acb99f05 100644 --- a/Database/Condition/LikeCondition.php +++ b/Database/Condition/LikeCondition.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace Database\Condition; -use Snowflake\Core\Str; +use Kiri\Core\Str; /** * Class LikeCondition diff --git a/Database/Condition/NotLikeCondition.php b/Database/Condition/NotLikeCondition.php index 585726af..9787d625 100644 --- a/Database/Condition/NotLikeCondition.php +++ b/Database/Condition/NotLikeCondition.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace Database\Condition; -use Snowflake\Core\Str; +use Kiri\Core\Str; /** * Class NotLikeCondition diff --git a/Database/Condition/RLikeCondition.php b/Database/Condition/RLikeCondition.php index 2bc1d3a8..4f3aec6b 100644 --- a/Database/Condition/RLikeCondition.php +++ b/Database/Condition/RLikeCondition.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace Database\Condition; -use Snowflake\Core\Str; +use Kiri\Core\Str; /** * Class RLikeCondition diff --git a/Database/Connection.php b/Database/Connection.php index b3aff5a5..0f695add 100644 --- a/Database/Connection.php +++ b/Database/Connection.php @@ -22,12 +22,12 @@ use PDO; use ReflectionException; use Server\Events\OnWorkerExit; use Server\Events\OnWorkerStop; -use Snowflake\Abstracts\Component; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Events\EventProvider; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Events\EventProvider; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** * Class Connection @@ -146,7 +146,7 @@ class Connection extends Component public function getSchema(): Schema { if ($this->_schema === null) { - $this->_schema = Snowflake::createObject([ + $this->_schema = Kiri::createObject([ 'class' => Schema::class, 'db' => $this ]); @@ -176,7 +176,7 @@ class Connection extends Component if (!$this->enableCache) { return null; } - return Snowflake::app()->get($this->cacheDriver); + return Kiri::app()->get($this->cacheDriver); } /** @@ -210,12 +210,12 @@ class Connection extends Component /** - * @return \Snowflake\Pool\Connection + * @return \Kiri\Pool\Connection * @throws Exception */ - private function connections(): \Snowflake\Pool\Connection + private function connections(): \Kiri\Pool\Connection { - return Snowflake::getDi()->get(\Snowflake\Pool\Connection::class); + return Kiri::getDi()->get(\Kiri\Pool\Connection::class); } @@ -293,7 +293,7 @@ class Connection extends Component */ public function release() { - if (!Snowflake::isWorker() && !Snowflake::isProcess()) { + if (!Kiri::isWorker() && !Kiri::isProcess()) { $this->clear_connection(); return; } diff --git a/Database/DatabasesProviders.php b/Database/DatabasesProviders.php index 788da13a..12bcf8a9 100644 --- a/Database/DatabasesProviders.php +++ b/Database/DatabasesProviders.php @@ -7,12 +7,12 @@ namespace Database; use Annotation\Inject; use Exception; use Server\Events\OnWorkerStart; -use Snowflake\Abstracts\Config; -use Snowflake\Abstracts\Providers; -use Snowflake\Application; -use Snowflake\Events\EventProvider; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Abstracts\Providers; +use Kiri\Application; +use Kiri\Events\EventProvider; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; /** * Class DatabasesProviders @@ -53,7 +53,7 @@ class DatabasesProviders extends Providers */ public function get($name): Connection { - $application = Snowflake::app(); + $application = Kiri::app(); if (!$application->has('databases.' . $name)) { $application->set('databases.' . $name, $this->_settings($this->getConfig($name))); } @@ -71,7 +71,7 @@ class DatabasesProviders extends Providers if (empty($databases)) { return; } - $application = Snowflake::app(); + $application = Kiri::app(); foreach ($databases as $name => $database) { /** @var Connection $connection */ $application->set('databases.' . $name, $this->_settings($database)); diff --git a/Database/Db.php b/Database/Db.php index 30961361..dbd62321 100644 --- a/Database/Db.php +++ b/Database/Db.php @@ -14,9 +14,9 @@ use Database\Affair\Commit; use Database\Affair\Rollback; use Database\Traits\QueryTrait; use Exception; -use Snowflake\Abstracts\Config; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\ConfigException; +use Kiri\Abstracts\Config; +use Kiri\Events\EventDispatch; +use Kiri\Exception\ConfigException; /** * Class Db diff --git a/Database/Mysql/Columns.php b/Database/Mysql/Columns.php index b235a021..f23f8889 100644 --- a/Database/Mysql/Columns.php +++ b/Database/Mysql/Columns.php @@ -15,8 +15,8 @@ use Database\Connection; use Database\SqlBuilder; use Exception; use JetBrains\PhpStorm\Pure; -use Snowflake\Abstracts\Component; -use Snowflake\Core\Json; +use Kiri\Abstracts\Component; +use Kiri\Core\Json; /** * Class Columns diff --git a/Database/Mysql/Schema.php b/Database/Mysql/Schema.php index 7a54b0b9..9cf42f4e 100644 --- a/Database/Mysql/Schema.php +++ b/Database/Mysql/Schema.php @@ -4,7 +4,7 @@ namespace Database\Mysql; use Exception; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; use Database\Connection; /** diff --git a/Database/Pagination.php b/Database/Pagination.php index aeab2149..35503fbd 100644 --- a/Database/Pagination.php +++ b/Database/Pagination.php @@ -6,7 +6,7 @@ namespace Database; use Closure; use Exception; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** * Class Pagination diff --git a/Database/Relation.php b/Database/Relation.php index 283da608..42965878 100644 --- a/Database/Relation.php +++ b/Database/Relation.php @@ -5,11 +5,11 @@ namespace Database; use Exception; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** * Class Relation - * @package Snowflake\db + * @package Kiri\db */ class Relation extends Component { diff --git a/Database/SqlBuilder.php b/Database/SqlBuilder.php index 0860f5aa..30a9c91a 100644 --- a/Database/SqlBuilder.php +++ b/Database/SqlBuilder.php @@ -7,7 +7,7 @@ namespace Database; use Database\Traits\Builder; use Exception; use JetBrains\PhpStorm\Pure; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** diff --git a/Database/Traits/Builder.php b/Database/Traits/Builder.php index d5e84af5..ea7d12ea 100644 --- a/Database/Traits/Builder.php +++ b/Database/Traits/Builder.php @@ -13,8 +13,8 @@ use Database\SqlBuilder; use Exception; use JetBrains\PhpStorm\Pure; use ReflectionException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** @@ -181,13 +181,13 @@ trait Builder if (!is_string($condition[2])) { $condition[2] = $this->_hashMap($condition[2]); } - $builder = Snowflake::createObject(['class' => OrCondition::class, 'value' => $condition[2], 'column' => $condition[1], 'oldParams' => $array]); + $builder = Kiri::createObject(['class' => OrCondition::class, 'value' => $condition[2], 'column' => $condition[1], 'oldParams' => $array]); } else if (isset(ConditionClassMap::$conditionMap[$stroppier])) { $defaultConfig = ConditionClassMap::$conditionMap[$stroppier]; $create = array_merge($defaultConfig, ['column' => $condition[1], 'value' => $condition[2]]); - $builder = Snowflake::createObject($create); + $builder = Kiri::createObject($create); } else { - $builder = Snowflake::createObject(['class' => HashCondition::class, 'value' => $condition]); + $builder = Kiri::createObject(['class' => HashCondition::class, 'value' => $condition]); } $array[] = $builder->builder(); diff --git a/Database/Traits/QueryTrait.php b/Database/Traits/QueryTrait.php index ff89f31c..9daac69f 100644 --- a/Database/Traits/QueryTrait.php +++ b/Database/Traits/QueryTrait.php @@ -18,8 +18,8 @@ use Database\Query; use Database\SqlBuilder; use Exception; use ReflectionException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** * Trait QueryTrait @@ -737,7 +737,7 @@ trait QueryTrait */ public function makeNewSqlGenerate(): Query { - return Snowflake::createObject(['class' => Query::class]); + return Kiri::createObject(['class' => Query::class]); } diff --git a/Gii/Command.php b/Gii/Command.php index 03c35f3b..a23d716a 100644 --- a/Gii/Command.php +++ b/Gii/Command.php @@ -5,10 +5,10 @@ namespace Gii; use Exception; -use Snowflake\Abstracts\Config; -use Snowflake\Abstracts\Input; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Abstracts\Input; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; /** * Class Command @@ -31,9 +31,9 @@ class Command extends \Console\Command public function onHandler(Input $dtl): array { /** @var Gii $gii */ - $gii = Snowflake::app()->get('gii'); + $gii = Kiri::app()->get('gii'); - $connections = Snowflake::app()->db; + $connections = Kiri::app()->db; if ($dtl->exists('databases')) { return $gii->run($connections->get($dtl->get('databases')), $dtl); } diff --git a/Gii/Gii.php b/Gii/Gii.php index b52a8a30..42f42c1b 100644 --- a/Gii/Gii.php +++ b/Gii/Gii.php @@ -12,10 +12,10 @@ namespace Gii; use Database\Connection; use Database\Db; use Exception; -use Snowflake\Abstracts\Input; -use Snowflake\Exception\ComponentException; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Input; +use Kiri\Exception\ComponentException; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; /** * Class gii @@ -123,7 +123,7 @@ class Gii return $this->makeByDatabases($make, $input); } $db = $this->input->get('databases', 'db'); - $this->db = Snowflake::app()->db->get($db); + $this->db = Kiri::app()->db->get($db); return $this->makeByDatabases($make, $input); } @@ -138,7 +138,7 @@ class Gii */ private function makeByDatabases($make, $input): array { - $redis = Snowflake::app()->getRedis(); + $redis = Kiri::app()->getRedis(); if (!empty($input->get('name'))) { $this->tableName = $input->get('name'); $redis->del('column:' . $this->tableName); diff --git a/Gii/GiiBase.php b/Gii/GiiBase.php index b24d1996..4bcf9a84 100644 --- a/Gii/GiiBase.php +++ b/Gii/GiiBase.php @@ -11,8 +11,8 @@ use JetBrains\PhpStorm\ArrayShape; use ReflectionClass; use ReflectionException; -use Snowflake\Abstracts\Input; -use Snowflake\Core\Json; +use Kiri\Abstracts\Input; +use Kiri\Core\Json; /** * Class GiiBase diff --git a/Gii/GiiController.php b/Gii/GiiController.php index 430762aa..1949a8ee 100644 --- a/Gii/GiiController.php +++ b/Gii/GiiController.php @@ -6,7 +6,7 @@ namespace Gii; use Exception; use ReflectionException; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class GiiController @@ -66,13 +66,13 @@ namespace {$namespace}; exit(logger()->addError($Exception, 'throwable')); } } else { - $import = "use Snowflake; + $import = "use Kiri; use Exception; use Annotation\Target; use Annotation\Route\Middleware; use Annotation\Route\Route; -use Snowflake\Core\Str; -use Snowflake\Core\Json; +use Kiri\Core\Str; +use Kiri\Core\Json; use HttpServer\Http\Request; use HttpServer\Http\Response; use HttpServer\Controller; @@ -127,7 +127,7 @@ use {$model_namespace}\\{$managerName}; unlink($file); } - Snowflake::writeFile($file, $html); + Kiri::writeFile($file, $html); return $controllerName . 'Controller.php'; } diff --git a/Gii/GiiInterceptor.php b/Gii/GiiInterceptor.php index 707f5ef7..af342381 100644 --- a/Gii/GiiInterceptor.php +++ b/Gii/GiiInterceptor.php @@ -6,7 +6,7 @@ namespace Gii; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class GiiInterceptor @@ -91,7 +91,7 @@ class ' . $managerName . 'Interceptor implements Interceptor throw new Exception('File exists.'); } - Snowflake::writeFile($file, $html); + Kiri::writeFile($file, $html); return [$managerName . 'Interceptor.php']; } diff --git a/Gii/GiiLimits.php b/Gii/GiiLimits.php index d2233701..c4aad2a0 100644 --- a/Gii/GiiLimits.php +++ b/Gii/GiiLimits.php @@ -6,7 +6,7 @@ namespace Gii; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class GiiLimits @@ -68,7 +68,7 @@ class ' . $managerName . 'Limits implements Limits throw new Exception('File exists.'); } - Snowflake::writeFile($file, $html); + Kiri::writeFile($file, $html); return [$managerName . 'Limits.php']; } diff --git a/Gii/GiiMiddleware.php b/Gii/GiiMiddleware.php index 43bd4318..4f53b50d 100644 --- a/Gii/GiiMiddleware.php +++ b/Gii/GiiMiddleware.php @@ -6,7 +6,7 @@ namespace Gii; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class GiiMiddleware @@ -65,7 +65,7 @@ class ' . $managerName . 'Middleware implements Middleware throw new Exception('File exists.'); } - Snowflake::writeFile($file, $html); + Kiri::writeFile($file, $html); return [$managerName . 'Middleware.php']; } diff --git a/Gii/GiiModel.php b/Gii/GiiModel.php index 4ed87eb4..b45bda97 100644 --- a/Gii/GiiModel.php +++ b/Gii/GiiModel.php @@ -7,7 +7,7 @@ namespace Gii; use Database\Db; use Exception; use ReflectionException; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class GiiModel @@ -57,7 +57,7 @@ class GiiModel extends GiiBase try { $className = str_replace('\\\\', '\\', "{$modelPath['namespace']}\\{$managerName}"); - $class = Snowflake::getDi()->getReflect($className); + $class = Kiri::getDi()->getReflect($className); $html = ' $database) { /** @var Connection $connection */ $connection = $application->get('databases.' . $name, false); @@ -101,7 +101,7 @@ abstract class Callback extends HttpService */ protected function clearRedisClient() { - $redis = Snowflake::app()->getRedis(); + $redis = Kiri::app()->getRedis(); $redis->destroy(); } diff --git a/HttpServer/Abstracts/HttpService.php b/HttpServer/Abstracts/HttpService.php index 168bca14..2906a17b 100644 --- a/HttpServer/Abstracts/HttpService.php +++ b/HttpServer/Abstracts/HttpService.php @@ -5,8 +5,8 @@ namespace HttpServer\Abstracts; use Exception; -use Snowflake\Abstracts\Component; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Kiri; /** @@ -24,7 +24,7 @@ abstract class HttpService extends Component */ protected function write($message, string $category = 'app') { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->write($message, $category); $logger->insert(); } diff --git a/HttpServer/Abstracts/ServerBase.php b/HttpServer/Abstracts/ServerBase.php index f79eebba..fc710770 100644 --- a/HttpServer/Abstracts/ServerBase.php +++ b/HttpServer/Abstracts/ServerBase.php @@ -13,7 +13,7 @@ use Swoole\WebSocket\Server; /** * Class OnServerDefault - * @package Snowflake\Snowflake\Server + * @package Kiri\Kiri\Server */ abstract class ServerBase extends HttpService { diff --git a/HttpServer/Client/Help/Client.php b/HttpServer/Client/Help/Client.php index 51bed866..9cc8ee53 100644 --- a/HttpServer/Client/Help/Client.php +++ b/HttpServer/Client/Help/Client.php @@ -15,7 +15,7 @@ use Swoole\Coroutine\Http\Client as SClient; /** * Class Client - * @package Snowflake\Snowflake\Http + * @package Kiri\Kiri\Http */ class Client extends ClientAbstracts { diff --git a/HttpServer/Client/Help/ClientAbstracts.php b/HttpServer/Client/Help/ClientAbstracts.php index 7ef25b2a..38644083 100644 --- a/HttpServer/Client/Help/ClientAbstracts.php +++ b/HttpServer/Client/Help/ClientAbstracts.php @@ -6,8 +6,8 @@ namespace HttpServer\Client\Help; use Closure; use JetBrains\PhpStorm\Pure; -use Snowflake\Abstracts\Component; -use Snowflake\Core\Help; +use Kiri\Abstracts\Component; +use Kiri\Core\Help; use Swoole\Coroutine\System; defined('SPLIT_URL') or define('SPLIT_URL', '/(http[s]?:\/\/)?(([\w\-_]+\.)+\w+(:\d+)?)((\/[a-zA-Z0-9\-]+)+[\/]?(\?[a-zA-Z]+=.*)?)?/'); diff --git a/HttpServer/Client/Http2.php b/HttpServer/Client/Http2.php index 3a88f57a..21aeaeeb 100644 --- a/HttpServer/Client/Http2.php +++ b/HttpServer/Client/Http2.php @@ -7,13 +7,13 @@ namespace HttpServer\Client; use Exception; use HttpServer\Http\Context; use Server\Events\OnAfterRequest; -use Snowflake\Abstracts\Component; -use Snowflake\Channel; -use Snowflake\Core\Json; -use Snowflake\Core\Xml; -use Snowflake\Event; -use Snowflake\Events\EventProvider; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Channel; +use Kiri\Core\Json; +use Kiri\Core\Xml; +use Kiri\Event; +use Kiri\Events\EventProvider; +use Kiri\Kiri; use Swoole\Coroutine\Http2\Client as H2Client; use Swoole\Http2\Request; use Swoole\Http2\Response; diff --git a/HttpServer/Client/HttpClient.php b/HttpServer/Client/HttpClient.php index 4c46db35..bbc2da7d 100644 --- a/HttpServer/Client/HttpClient.php +++ b/HttpServer/Client/HttpClient.php @@ -5,8 +5,8 @@ namespace HttpServer\Client; use Exception; -use Snowflake\Abstracts\Component; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Kiri; use Swoole\Coroutine; use HttpServer\Client\Help\IClient; use HttpServer\Client\Help\Client; @@ -34,7 +34,7 @@ class HttpClient extends Component */ public static function http2(): Http2 { - return Snowflake::app()->get('http2'); + return Kiri::app()->get('http2'); } } diff --git a/HttpServer/Command.php b/HttpServer/Command.php index 6ebccc59..d8e2b0f1 100644 --- a/HttpServer/Command.php +++ b/HttpServer/Command.php @@ -5,9 +5,9 @@ namespace HttpServer; use Exception; -use Snowflake\Abstracts\Input; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Input; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; /** * Class Command @@ -33,14 +33,14 @@ class Command extends \Console\Command */ public function onHandler(Input $dtl): string { - $manager = Snowflake::app()->getServer(); + $manager = Kiri::app()->getServer(); $manager->setDaemon($dtl->get('daemon', 0)); if (!in_array($dtl->get('action'), self::ACTIONS)) { return 'I don\'t know what I want to do.'; } /** @var Shutdown $shutdown */ - $shutdown = Snowflake::app()->get('shutdown'); + $shutdown = Kiri::app()->get('shutdown'); if ($shutdown->isRunning() && $dtl->get('action') == 'start') { return 'Service is running. Please use restart.'; } diff --git a/HttpServer/Controller.php b/HttpServer/Controller.php index 6734db99..05364706 100644 --- a/HttpServer/Controller.php +++ b/HttpServer/Controller.php @@ -8,15 +8,15 @@ use Annotation\Inject; use HttpServer\Http\HttpHeaders; use HttpServer\Http\HttpParams; use HttpServer\Http\Request; -use Snowflake\Abstracts\TraitApplication; -use Snowflake\Application; +use Kiri\Abstracts\TraitApplication; +use Kiri\Application; use Server\Constrict\Response as CrResponse; use Server\Constrict\Request as CrRequest; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class WebController - * @package Snowflake\Snowflake\Web + * @package Kiri\Kiri\Web * @property Application $container */ class Controller diff --git a/HttpServer/Events/OnAfterReload.php b/HttpServer/Events/OnAfterReload.php index 8f110b20..587ac283 100644 --- a/HttpServer/Events/OnAfterReload.php +++ b/HttpServer/Events/OnAfterReload.php @@ -6,9 +6,9 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; -use Snowflake\Exception\ComponentException; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Exception\ComponentException; +use Kiri\Kiri; use Swoole\Server; /** diff --git a/HttpServer/Events/OnBeforeReload.php b/HttpServer/Events/OnBeforeReload.php index 16704da0..c29f3db6 100644 --- a/HttpServer/Events/OnBeforeReload.php +++ b/HttpServer/Events/OnBeforeReload.php @@ -6,8 +6,8 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; use Swoole\Timer; @@ -26,8 +26,8 @@ class OnBeforeReload extends Callback { Event::trigger(Event::SERVER_BEFORE_RELOAD, [$server]); - Snowflake::clearWorkerPid(); - Snowflake::clearTaskPid(); + Kiri::clearWorkerPid(); + Kiri::clearTaskPid(); } } diff --git a/HttpServer/Events/OnClose.php b/HttpServer/Events/OnClose.php index 67ae2dbb..d29c9664 100644 --- a/HttpServer/Events/OnClose.php +++ b/HttpServer/Events/OnClose.php @@ -6,7 +6,7 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; +use Kiri\Event; use Swoole\Server; /** diff --git a/HttpServer/Events/OnConnect.php b/HttpServer/Events/OnConnect.php index 704d0b10..63c9755f 100644 --- a/HttpServer/Events/OnConnect.php +++ b/HttpServer/Events/OnConnect.php @@ -6,7 +6,7 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; +use Kiri\Event; use Swoole\Server; /** diff --git a/HttpServer/Events/OnFinish.php b/HttpServer/Events/OnFinish.php index fc0c2af2..7b7c17a4 100644 --- a/HttpServer/Events/OnFinish.php +++ b/HttpServer/Events/OnFinish.php @@ -6,8 +6,8 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; /** diff --git a/HttpServer/Events/OnHandshake.php b/HttpServer/Events/OnHandshake.php index 566ebee5..dcbea0ed 100644 --- a/HttpServer/Events/OnHandshake.php +++ b/HttpServer/Events/OnHandshake.php @@ -13,10 +13,10 @@ use HttpServer\Http\Request; use HttpServer\Http\Response; use HttpServer\Route\Router; use ReflectionException; -use Snowflake\Core\ArrayAccess; -use Snowflake\Event; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Core\ArrayAccess; +use Kiri\Event; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use Swoole\Http\Request as SRequest; use Swoole\Http\Response as SResponse; use Swoole\WebSocket\Server; @@ -57,7 +57,7 @@ class OnHandshake extends Callback foreach ($headers as $key => $val) { $response->header($key, $val); } - return Snowflake::app()->getRouter(); + return Kiri::app()->getRouter(); } @@ -68,7 +68,7 @@ class OnHandshake extends Callback */ private function disconnect(SResponse $response, int $code = 500): void { - $server = Snowflake::getWebSocket(); + $server = Kiri::getWebSocket(); if (!$server->isEstablished($response->fd)) { return; } diff --git a/HttpServer/Events/OnManagerStart.php b/HttpServer/Events/OnManagerStart.php index 69c6d2a2..dc6593a2 100644 --- a/HttpServer/Events/OnManagerStart.php +++ b/HttpServer/Events/OnManagerStart.php @@ -6,9 +6,9 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; @@ -26,7 +26,7 @@ class OnManagerStart extends Callback */ public function onHandler(Server $server) { - Snowflake::setWorkerId($server->manager_pid); + Kiri::setWorkerId($server->manager_pid); fire(Event::SERVER_MANAGER_START, [$server]); diff --git a/HttpServer/Events/OnManagerStop.php b/HttpServer/Events/OnManagerStop.php index 4be6717a..8c5e991f 100644 --- a/HttpServer/Events/OnManagerStop.php +++ b/HttpServer/Events/OnManagerStop.php @@ -6,8 +6,8 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; /** diff --git a/HttpServer/Events/OnMessage.php b/HttpServer/Events/OnMessage.php index 4d41f4d5..70b7b3de 100644 --- a/HttpServer/Events/OnMessage.php +++ b/HttpServer/Events/OnMessage.php @@ -5,7 +5,7 @@ namespace HttpServer\Events; use HttpServer\Abstracts\Callback; -use Snowflake\Event; +use Kiri\Event; use Swoole\WebSocket\Frame; use Swoole\WebSocket\Server; diff --git a/HttpServer/Events/OnPacket.php b/HttpServer/Events/OnPacket.php index b9b4bfcc..b7c72bf4 100644 --- a/HttpServer/Events/OnPacket.php +++ b/HttpServer/Events/OnPacket.php @@ -6,8 +6,8 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Core\Json; -use Snowflake\Event; +use Kiri\Core\Json; +use Kiri\Event; use Swoole\Server; /** diff --git a/HttpServer/Events/OnPipeMessage.php b/HttpServer/Events/OnPipeMessage.php index c48587f2..910869b8 100644 --- a/HttpServer/Events/OnPipeMessage.php +++ b/HttpServer/Events/OnPipeMessage.php @@ -7,10 +7,10 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; use Kafka\Struct; -use Snowflake\Crontab\Crontab; -use Snowflake\Crontab\Producer; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Crontab\Crontab; +use Kiri\Crontab\Producer; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; /** diff --git a/HttpServer/Events/OnReceive.php b/HttpServer/Events/OnReceive.php index 681de9e6..b9624aef 100644 --- a/HttpServer/Events/OnReceive.php +++ b/HttpServer/Events/OnReceive.php @@ -7,9 +7,9 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; use HttpServer\Http\Request; -use Snowflake\Abstracts\Config; -use Snowflake\Core\Json; -use Snowflake\Event; +use Kiri\Abstracts\Config; +use Kiri\Core\Json; +use Kiri\Event; use Swoole\Server; /** diff --git a/HttpServer/Events/OnRequest.php b/HttpServer/Events/OnRequest.php index eefc1b21..ebdd9f09 100644 --- a/HttpServer/Events/OnRequest.php +++ b/HttpServer/Events/OnRequest.php @@ -10,9 +10,9 @@ use HttpServer\Exception\ExitException; use HttpServer\Http\Request as HRequest; use HttpServer\Http\Response as HResponse; use HttpServer\Route\Router; -use Snowflake\Error\Logger; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Error\Logger; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Error; use Swoole\Http\Request; use Swoole\Http\Response; @@ -38,7 +38,7 @@ class OnRequest extends Callback */ public function init() { - $this->router = Snowflake::app()->getRouter(); + $this->router = Kiri::app()->getRouter(); } diff --git a/HttpServer/Events/OnShutdown.php b/HttpServer/Events/OnShutdown.php index ccd4d2ac..abb8c455 100644 --- a/HttpServer/Events/OnShutdown.php +++ b/HttpServer/Events/OnShutdown.php @@ -6,9 +6,9 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; -use Snowflake\Exception\ComponentException; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Exception\ComponentException; +use Kiri\Kiri; use Swoole\Server; /** diff --git a/HttpServer/Events/OnStart.php b/HttpServer/Events/OnStart.php index 820a673e..7c833d18 100644 --- a/HttpServer/Events/OnStart.php +++ b/HttpServer/Events/OnStart.php @@ -6,9 +6,9 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; /** @@ -24,7 +24,7 @@ class OnStart extends Callback */ public function onHandler(Server $server) { - if (Snowflake::getPlatform()->isLinux()) { + if (Kiri::getPlatform()->isLinux()) { name($server->master_pid, 'master'); } fire(Event::SERVER_EVENT_START, [$server]); diff --git a/HttpServer/Events/OnTask.php b/HttpServer/Events/OnTask.php index a1cf1e87..5f26c522 100644 --- a/HttpServer/Events/OnTask.php +++ b/HttpServer/Events/OnTask.php @@ -8,9 +8,9 @@ namespace HttpServer\Events; use HttpServer\Abstracts\Callback; use HttpServer\IInterface\Task; use HttpServer\IInterface\Task as ITask; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Coroutine; use Swoole\Process; use Swoole\Server; @@ -29,7 +29,7 @@ class OnTask extends Callback */ public function onHandler() { - $setting = Snowflake::app()->getSwoole(); + $setting = Kiri::app()->getSwoole(); $isCoroutineTask = $setting->setting['task_enable_coroutine'] ?? false; if ($isCoroutineTask === true) { diff --git a/HttpServer/Events/OnWorkerError.php b/HttpServer/Events/OnWorkerError.php index b7545810..fe06defd 100644 --- a/HttpServer/Events/OnWorkerError.php +++ b/HttpServer/Events/OnWorkerError.php @@ -6,9 +6,9 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Server; /** diff --git a/HttpServer/Events/OnWorkerExit.php b/HttpServer/Events/OnWorkerExit.php index e901223e..2156a6da 100644 --- a/HttpServer/Events/OnWorkerExit.php +++ b/HttpServer/Events/OnWorkerExit.php @@ -6,8 +6,8 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Kiri; use Swoole\Timer; /** @@ -28,7 +28,7 @@ class OnWorkerExit extends Callback Event::trigger(Event::SERVER_WORKER_EXIT, [$server, $worker_id]); - Snowflake::getApp('logger')->insert(); + Kiri::getApp('logger')->insert(); } } diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 06e9a61e..bbeaeaba 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -6,11 +6,11 @@ namespace HttpServer\Events; use Annotation\Annotation; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Exception\ConfigException; -use Snowflake\Runtime; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Exception\ConfigException; +use Kiri\Runtime; +use Kiri\Kiri; use Swoole\Server; /** @@ -32,7 +32,7 @@ class OnWorkerStart extends Callback { $this->setConfigs($worker_id); - $annotation = Snowflake::app()->getAnnotation(); + $annotation = Kiri::app()->getAnnotation(); $annotation->setLoader(unserialize(file_get_contents(storage(Runtime::CACHE_NAME)))); if ($worker_id >= $server->setting['worker_num']) { $this->onTask($server, $annotation); @@ -78,13 +78,13 @@ class OnWorkerStart extends Callback */ public function onTask(Server $server, Annotation $annotation) { - putenv('environmental=' . Snowflake::TASK); + putenv('environmental=' . Kiri::TASK); $annotation->runtime(APP_PATH, [CONTROLLER_PATH, TASK_PATH, LISTENER_PATH]); name($server->worker_pid, 'Task#' . $server->worker_id); - Snowflake::setTaskId($server->worker_pid); + Kiri::setTaskId($server->worker_pid); fire(Event::SERVER_TASK_START); } @@ -106,8 +106,8 @@ class OnWorkerStart extends Callback $this->debug('use time.' . (microtime(true) - $time)); $annotation->runtime(directory('app'), [CONTROLLER_PATH]); - Snowflake::setWorkerId($server->worker_pid); - putenv('environmental=' . Snowflake::WORKER); + Kiri::setWorkerId($server->worker_pid); + putenv('environmental=' . Kiri::WORKER); fire(Event::SERVER_WORKER_START, [getenv('worker')]); } diff --git a/HttpServer/Events/OnWorkerStop.php b/HttpServer/Events/OnWorkerStop.php index 589eec86..abf3ac68 100644 --- a/HttpServer/Events/OnWorkerStop.php +++ b/HttpServer/Events/OnWorkerStop.php @@ -6,7 +6,7 @@ namespace HttpServer\Events; use Exception; use HttpServer\Abstracts\Callback; -use Snowflake\Event; +use Kiri\Event; use Swoole\Timer; /** diff --git a/HttpServer/Exception/AuthException.php b/HttpServer/Exception/AuthException.php index 4a277f94..28c97449 100644 --- a/HttpServer/Exception/AuthException.php +++ b/HttpServer/Exception/AuthException.php @@ -14,7 +14,7 @@ use Throwable; /** * Class AuthException - * @package Snowflake\Snowflake\Exception + * @package Kiri\Kiri\Exception */ class AuthException extends \Exception { diff --git a/HttpServer/Http/CoroutineResponse.php b/HttpServer/Http/CoroutineResponse.php index 43682ccf..d387b2e3 100644 --- a/HttpServer/Http/CoroutineResponse.php +++ b/HttpServer/Http/CoroutineResponse.php @@ -10,8 +10,8 @@ use HttpServer\Http\Formatter\HtmlFormatter; use HttpServer\Http\Formatter\JsonFormatter; use HttpServer\Http\Formatter\XmlFormatter; use HttpServer\IInterface\IFormatter; -use Snowflake\Core\Help; -use Snowflake\Snowflake; +use Kiri\Core\Help; +use Kiri\Kiri; use Swoole\Http\Response as SResponse; @@ -178,7 +178,7 @@ class CoroutineResponse extends HttpService /** @var IFormatter $class */ $class = $this->_format_maps[$this->format] ?? HtmlFormatter::class; - $di = Snowflake::getDi()->get($class); + $di = Kiri::getDi()->get($class); $context = $di->send($context)->getData(); } return $context; diff --git a/HttpServer/Http/File.php b/HttpServer/Http/File.php index 44c818ba..76b385dc 100644 --- a/HttpServer/Http/File.php +++ b/HttpServer/Http/File.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace HttpServer\Http; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class File diff --git a/HttpServer/Http/Formatter/HtmlFormatter.php b/HttpServer/Http/Formatter/HtmlFormatter.php index 63d39119..864b864e 100644 --- a/HttpServer/Http/Formatter/HtmlFormatter.php +++ b/HttpServer/Http/Formatter/HtmlFormatter.php @@ -12,13 +12,13 @@ namespace HttpServer\Http\Formatter; use Exception; use HttpServer\Abstracts\HttpService; -use Snowflake\Core\Json; +use Kiri\Core\Json; use Swoole\Http\Response; use HttpServer\IInterface\IFormatter; /** * Class HtmlFormatter - * @package Snowflake\Snowflake\Http\Formatter + * @package Kiri\Kiri\Http\Formatter */ class HtmlFormatter extends HttpService implements IFormatter { diff --git a/HttpServer/Http/Formatter/JsonFormatter.php b/HttpServer/Http/Formatter/JsonFormatter.php index 7799b1c0..9620e28c 100644 --- a/HttpServer/Http/Formatter/JsonFormatter.php +++ b/HttpServer/Http/Formatter/JsonFormatter.php @@ -14,7 +14,7 @@ use HttpServer\IInterface\IFormatter; /** * Class JsonFormatter - * @package Snowflake\Snowflake\Http\Formatter + * @package Kiri\Kiri\Http\Formatter */ class JsonFormatter extends HttpService implements IFormatter { diff --git a/HttpServer/Http/Formatter/XmlFormatter.php b/HttpServer/Http/Formatter/XmlFormatter.php index 98c045f0..1973ff13 100644 --- a/HttpServer/Http/Formatter/XmlFormatter.php +++ b/HttpServer/Http/Formatter/XmlFormatter.php @@ -19,7 +19,7 @@ use HttpServer\IInterface\IFormatter; /** * Class XmlFormatter - * @package Snowflake\Snowflake\Http\Formatter + * @package Kiri\Kiri\Http\Formatter */ class XmlFormatter extends HttpService implements IFormatter { diff --git a/HttpServer/Http/HttpHeaders.php b/HttpServer/Http/HttpHeaders.php index f03e2c3d..d3c84e12 100644 --- a/HttpServer/Http/HttpHeaders.php +++ b/HttpServer/Http/HttpHeaders.php @@ -11,7 +11,7 @@ namespace HttpServer\Http; /** * Class HttpHeaders - * @package Snowflake\Snowflake\Http + * @package Kiri\Kiri\Http */ trait HttpHeaders { diff --git a/HttpServer/Http/HttpParams.php b/HttpServer/Http/HttpParams.php index 16a8e7e3..faaac43c 100644 --- a/HttpServer/Http/HttpParams.php +++ b/HttpServer/Http/HttpParams.php @@ -12,14 +12,14 @@ namespace HttpServer\Http; use Exception; use HttpServer\Exception\RequestException; use ReflectionException; -use Snowflake\Core\Json; -use Snowflake\Core\Xml; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Core\Json; +use Kiri\Core\Xml; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** * Class HttpParams - * @package Snowflake\Snowflake\Http + * @package Kiri\Kiri\Http */ trait HttpParams { @@ -204,7 +204,7 @@ trait HttpParams $param = $this->_files[$name] ?? null; if (!empty($param)) { $param['class'] = File::class; - return Snowflake::createObject($param); + return Kiri::createObject($param); } return null; } diff --git a/HttpServer/Http/Request.php b/HttpServer/Http/Request.php index d6528656..6b1733f1 100644 --- a/HttpServer/Http/Request.php +++ b/HttpServer/Http/Request.php @@ -10,7 +10,7 @@ use HttpServer\IInterface\AuthIdentity; use JetBrains\PhpStorm\Pure; use Server\RequestInterface; use Server\ServerManager; -use Snowflake\Core\Json; +use Kiri\Core\Json; defined('REQUEST_OK') or define('REQUEST_OK', 0); defined('REQUEST_FAIL') or define('REQUEST_FAIL', 500); @@ -18,7 +18,7 @@ defined('REQUEST_FAIL') or define('REQUEST_FAIL', 500); /** * Class HttpRequest * - * @package Snowflake\Snowflake\HttpRequest + * @package Kiri\Kiri\HttpRequest * * @property-read $isPost * @property-read $isGet diff --git a/HttpServer/Http/Response.php b/HttpServer/Http/Response.php index c9dcbb43..537c67ba 100644 --- a/HttpServer/Http/Response.php +++ b/HttpServer/Http/Response.php @@ -17,12 +17,12 @@ use HttpServer\Http\Formatter\JsonFormatter; use HttpServer\Http\Formatter\XmlFormatter; use HttpServer\IInterface\IFormatter; use Server\ResponseInterface; -use Snowflake\Exception\NotFindClassException; +use Kiri\Exception\NotFindClassException; use Swoole\Http\Response as SResponse; /** * Class Response - * @package Snowflake\Snowflake\Http + * @package Kiri\Kiri\Http */ class Response extends HttpService implements ResponseInterface { diff --git a/HttpServer/HttpFilter.php b/HttpServer/HttpFilter.php index c0ca954a..a0e05799 100644 --- a/HttpServer/HttpFilter.php +++ b/HttpServer/HttpFilter.php @@ -5,7 +5,7 @@ namespace HttpServer; use Exception; -use Snowflake\Abstracts\BaseObject; +use Kiri\Abstracts\BaseObject; use validator\Validator; /** diff --git a/HttpServer/IInterface/AuthIdentity.php b/HttpServer/IInterface/AuthIdentity.php index b7a5e0e0..2ecb3219 100644 --- a/HttpServer/IInterface/AuthIdentity.php +++ b/HttpServer/IInterface/AuthIdentity.php @@ -7,7 +7,7 @@ namespace HttpServer\IInterface; /** * Interface AuthIdentity - * @package Snowflake\Snowflake\Http + * @package Kiri\Kiri\Http */ interface AuthIdentity { diff --git a/HttpServer/IInterface/IFormatter.php b/HttpServer/IInterface/IFormatter.php index 30ebd2ff..7d3c02a9 100644 --- a/HttpServer/IInterface/IFormatter.php +++ b/HttpServer/IInterface/IFormatter.php @@ -12,7 +12,7 @@ namespace HttpServer\IInterface; /** * Interface IFormatter - * @package Snowflake\Snowflake\Http\Formatter + * @package Kiri\Kiri\Http\Formatter */ interface IFormatter { diff --git a/HttpServer/IInterface/Middleware.php b/HttpServer/IInterface/Middleware.php index b9bab7b6..e9d5ebb7 100644 --- a/HttpServer/IInterface/Middleware.php +++ b/HttpServer/IInterface/Middleware.php @@ -10,7 +10,7 @@ use HttpServer\Http\Request; /** * Interface IMiddleware - * @package Snowflake\Snowflake\Route + * @package Kiri\Kiri\Route */ interface Middleware { diff --git a/HttpServer/Route/Any.php b/HttpServer/Route/Any.php index 5f4a5793..8452f4b2 100644 --- a/HttpServer/Route/Any.php +++ b/HttpServer/Route/Any.php @@ -7,7 +7,7 @@ namespace HttpServer\Route; /** * Class Any - * @package Snowflake\Snowflake\Route + * @package Kiri\Kiri\Route */ class Any { diff --git a/HttpServer/Route/CoreMiddleware.php b/HttpServer/Route/CoreMiddleware.php index 1824a2cc..ba4e2624 100644 --- a/HttpServer/Route/CoreMiddleware.php +++ b/HttpServer/Route/CoreMiddleware.php @@ -12,11 +12,11 @@ use HttpServer\Http\Request; use HttpServer\Http\Response; use HttpServer\IInterface\Middleware; use Server\RequestInterface; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class CoreMiddleware - * @package Snowflake\Snowflake\Route + * @package Kiri\Kiri\Route * 跨域中间件 */ class CoreMiddleware implements Middleware @@ -36,7 +36,7 @@ class CoreMiddleware implements Middleware public function onHandler(RequestInterface $request, Closure $next): mixed { /** @var Response $response */ - $response = Snowflake::getApp('response'); + $response = Kiri::getApp('response'); $response->addHeader('Access-Control-Allow-Origin', '*'); $response->addHeader('Access-Control-Allow-Headers', $request->header('access-control-request-headers')); $response->addHeader('Access-Control-Request-Method', $request->header('access-control-request-method')); diff --git a/HttpServer/Route/HandlerProviders.php b/HttpServer/Route/HandlerProviders.php index 7dc4fe4c..4e5916f0 100644 --- a/HttpServer/Route/HandlerProviders.php +++ b/HttpServer/Route/HandlerProviders.php @@ -2,7 +2,7 @@ namespace HttpServer\Route; -use Snowflake\Abstracts\BaseObject; +use Kiri\Abstracts\BaseObject; /** diff --git a/HttpServer/Route/MiddlewareManager.php b/HttpServer/Route/MiddlewareManager.php index 80c1b19a..a3df3a76 100644 --- a/HttpServer/Route/MiddlewareManager.php +++ b/HttpServer/Route/MiddlewareManager.php @@ -6,7 +6,7 @@ namespace HttpServer\Route; use Closure; use HttpServer\IInterface\Middleware; -use Snowflake\Abstracts\BaseObject; +use Kiri\Abstracts\BaseObject; /** diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index a57763aa..2655aeb0 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -14,14 +14,14 @@ use HttpServer\Http\Request; use JetBrains\PhpStorm\Pure; use ReflectionException; use Server\Events\OnAfterWorkerStart; -use Snowflake\Events\EventProvider; -use Snowflake\Exception\NotFindClassException; -use Snowflake\IAspect; -use Snowflake\Snowflake; +use Kiri\Events\EventProvider; +use Kiri\Exception\NotFindClassException; +use Kiri\IAspect; +use Kiri\Kiri; /** * Class Node - * @package Snowflake\Snowflake\Route + * @package Kiri\Kiri\Route */ class Node { @@ -122,7 +122,7 @@ class Node if (!class_exists($controller) && !empty($this->namespace)) { $controller = implode('\\', $this->namespace) . '\\' . $controller; } - return [Snowflake::getDi()->get($controller), $action]; + return [Kiri::getDi()->get($controller), $action]; } @@ -150,7 +150,7 @@ class Node */ private function getHandlerProviders(): HandlerProviders { - return Snowflake::getDi()->get(HandlerProviders::class); + return Kiri::getDi()->get(HandlerProviders::class); } @@ -194,7 +194,7 @@ class Node */ public function setParameters(): static { - $container = Snowflake::getDi(); + $container = Kiri::getDi(); if (empty($this->_handler)) { return $this; } @@ -236,7 +236,7 @@ class Node private function getAop($handler): ?IAspect { [$controller, $action] = $handler; - $aspect = Snowflake::getDi()->getMethodAttribute($controller::class, $action); + $aspect = Kiri::getDi()->getMethodAttribute($controller::class, $action); if (empty($aspect)) { return null; } diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 60c4b8bc..573cc883 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -16,17 +16,17 @@ use JetBrains\PhpStorm\Pure; use ReflectionException; use Rpc\Actuator; use Server\RequestInterface; -use Snowflake\Abstracts\Config; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; defined('ROUTER_TREE') or define('ROUTER_TREE', 1); defined('ROUTER_HASH') or define('ROUTER_HASH', 2); /** * Class Router - * @package Snowflake\Snowflake\Route + * @package Kiri\Kiri\Route */ class Router extends HttpService implements RouterInterface { @@ -66,7 +66,7 @@ class Router extends HttpService implements RouterInterface { $this->dir = Config::get('http.namespace', $this->dir); - $this->response = Snowflake::app()->get('response'); + $this->response = Kiri::app()->get('response'); } @@ -347,7 +347,7 @@ class Router extends HttpService implements RouterInterface if (!is_string($value)) { return $value; } - $value = Snowflake::createObject($value); + $value = Kiri::createObject($value); if (!($value instanceof Middleware)) { return null; } @@ -462,7 +462,7 @@ class Router extends HttpService implements RouterInterface */ public function exception($exception): mixed { - return Snowflake::app()->getLogger()->exception($exception); + return Kiri::app()->getLogger()->exception($exception); } @@ -551,9 +551,9 @@ class Router extends HttpService implements RouterInterface public function _loader() { $this->loadRouteDir(APP_PATH . 'routes'); - $classes = Snowflake::getAnnotation()->runtime(CONTROLLER_PATH); + $classes = Kiri::getAnnotation()->runtime(CONTROLLER_PATH); - $di = Snowflake::getDi(); + $di = Kiri::getDi(); foreach ($classes as $class) { $instance = $di->get($class); $methods = $di->getMethodAttribute($class); diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 2fef1422..087daed3 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -14,12 +14,12 @@ use ReflectionException; use Rpc\Service; use Server\Constant; use Server\ServerManager; -use Snowflake\Abstracts\Config; -use Snowflake\Error\LoggerProcess; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Process\Biomonitoring; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Error\LoggerProcess; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Process\Biomonitoring; +use Kiri\Kiri; use Swoole\Runtime; @@ -163,7 +163,7 @@ class Server extends HttpService */ private function checkPort($port): bool { - if (Snowflake::getPlatform()->isLinux()) { + if (Kiri::getPlatform()->isLinux()) { exec('netstat -tunlp | grep ' . $port, $output); } else { exec('lsof -i :' . $port . ' | grep -i "LISTEN"', $output); @@ -181,7 +181,7 @@ class Server extends HttpService public function shutdown() { /** @var Shutdown $shutdown */ - $shutdown = Snowflake::app()->get('shutdown'); + $shutdown = Kiri::app()->get('shutdown'); $shutdown->shutdown(); } diff --git a/HttpServer/ServerProviders.php b/HttpServer/ServerProviders.php index c720bf98..65295956 100644 --- a/HttpServer/ServerProviders.php +++ b/HttpServer/ServerProviders.php @@ -6,8 +6,8 @@ namespace HttpServer; use Console\Console; use Exception; -use Snowflake\Abstracts\Providers; -use Snowflake\Application; +use Kiri\Abstracts\Providers; +use Kiri\Application; /** * Class DatabasesProviders diff --git a/HttpServer/Service/Abstracts/Server.php b/HttpServer/Service/Abstracts/Server.php index 2c5d8987..7038316e 100644 --- a/HttpServer/Service/Abstracts/Server.php +++ b/HttpServer/Service/Abstracts/Server.php @@ -6,9 +6,9 @@ namespace HttpServer\Service\Abstracts; use Exception; use ReflectionException; -use Snowflake\Application; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Application; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** @@ -114,7 +114,7 @@ trait Server throw new Exception('class not found.'); } - $class = Snowflake::createObject($classPrefix, [Snowflake::app()]); + $class = Kiri::createObject($classPrefix, [Kiri::app()]); return [$class, 'onHandler']; } diff --git a/HttpServer/Service/Http.php b/HttpServer/Service/Http.php index 9d4ead1c..a806efbd 100644 --- a/HttpServer/Service/Http.php +++ b/HttpServer/Service/Http.php @@ -5,7 +5,7 @@ namespace HttpServer\Service; use ReflectionException; -use Snowflake\Exception\NotFindClassException; +use Kiri\Exception\NotFindClassException; use HttpServer\Service\Abstracts\Http as AHttp; class Http extends AHttp diff --git a/HttpServer/Service/Packet.php b/HttpServer/Service/Packet.php index 32f0e74f..6e3db55e 100644 --- a/HttpServer/Service/Packet.php +++ b/HttpServer/Service/Packet.php @@ -6,7 +6,7 @@ namespace HttpServer\Service; use HttpServer\Service\Abstracts\Tcp; use ReflectionException; -use Snowflake\Exception\NotFindClassException; +use Kiri\Exception\NotFindClassException; /** * Class OnPacket diff --git a/HttpServer/Service/Receive.php b/HttpServer/Service/Receive.php index f8fb2cb8..71e7a761 100644 --- a/HttpServer/Service/Receive.php +++ b/HttpServer/Service/Receive.php @@ -6,7 +6,7 @@ namespace HttpServer\Service; use HttpServer\Service\Abstracts\Tcp; use ReflectionException; -use Snowflake\Exception\NotFindClassException; +use Kiri\Exception\NotFindClassException; /** * Class Receive diff --git a/HttpServer/Service/Websocket.php b/HttpServer/Service/Websocket.php index 5f891f64..ea95faa7 100644 --- a/HttpServer/Service/Websocket.php +++ b/HttpServer/Service/Websocket.php @@ -5,7 +5,7 @@ namespace HttpServer\Service; use ReflectionException; -use Snowflake\Exception\NotFindClassException; +use Kiri\Exception\NotFindClassException; use HttpServer\Service\Abstracts\Websocket as HAWebsocket; diff --git a/HttpServer/Shutdown.php b/HttpServer/Shutdown.php index 720e3f3d..ceb6e381 100644 --- a/HttpServer/Shutdown.php +++ b/HttpServer/Shutdown.php @@ -6,7 +6,7 @@ namespace HttpServer; use Exception; use Server\ServerManager; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** diff --git a/Kafka/Kafka.php b/Kafka/Kafka.php index f179d63f..080fd957 100644 --- a/Kafka/Kafka.php +++ b/Kafka/Kafka.php @@ -11,9 +11,9 @@ use RdKafka\Exception; use RdKafka\KafkaConsumer; use RdKafka\TopicConf; use Server\SInterface\CustomProcess; -use Snowflake\Abstracts\Config; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; use Swoole\Coroutine\Channel; use Swoole\Process; use Throwable; @@ -120,12 +120,12 @@ class Kafka implements CustomProcess { go(function () use ($topic, $message) { try { - $server = Snowflake::app()->getSwoole(); + $server = Kiri::app()->getSwoole(); $setting = $server->setting['worker_num']; /** @var KafkaProvider $container */ - $container = Snowflake::getDi()->get(KafkaProvider::class); + $container = Kiri::getDi()->get(KafkaProvider::class); $data = $container->getConsumer($topic); if (!empty($data)) { $server->sendMessage(new $data(new Struct($topic, $message)), random_int(0, $setting - 1)); diff --git a/Kafka/KafkaClient.php b/Kafka/KafkaClient.php index 4d5b0290..65a2f7d5 100644 --- a/Kafka/KafkaClient.php +++ b/Kafka/KafkaClient.php @@ -7,10 +7,10 @@ use RdKafka\Conf; use RdKafka\ProducerTopic; use RdKafka\TopicConf; use ReflectionException; -use Snowflake\Abstracts\Config; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** @@ -87,7 +87,7 @@ class KafkaClient */ private function getProducer(): \RdKafka\Producer { - return Snowflake::getDi()->get(\RdKafka\Producer::class, [$this->conf]); + return Kiri::getDi()->get(\RdKafka\Producer::class, [$this->conf]); } diff --git a/Kafka/KafkaImports.php b/Kafka/KafkaImports.php index eaaa89e7..acc45b6f 100644 --- a/Kafka/KafkaImports.php +++ b/Kafka/KafkaImports.php @@ -6,10 +6,10 @@ namespace Kafka; use Exception; use HttpServer\Server; -use Snowflake\Abstracts\Config; -use Snowflake\Abstracts\Config as SConfig; -use Snowflake\Abstracts\Providers; -use Snowflake\Application; +use Kiri\Abstracts\Config; +use Kiri\Abstracts\Config as SConfig; +use Kiri\Abstracts\Providers; +use Kiri\Application; /** diff --git a/Kafka/KafkaProvider.php b/Kafka/KafkaProvider.php index b15f0737..f5f85507 100644 --- a/Kafka/KafkaProvider.php +++ b/Kafka/KafkaProvider.php @@ -4,7 +4,7 @@ namespace Kafka; -use Snowflake\Abstracts\BaseObject; +use Kiri\Abstracts\BaseObject; /** diff --git a/Kafka/Logger.php b/Kafka/Logger.php index 7e663357..83f1d89e 100644 --- a/Kafka/Logger.php +++ b/Kafka/Logger.php @@ -6,7 +6,7 @@ namespace Kafka; use Exception; use Psr\Log\LoggerInterface; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class Logger @@ -33,7 +33,7 @@ class Logger implements LoggerInterface */ public function alert(mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->debug($message); } @@ -50,7 +50,7 @@ class Logger implements LoggerInterface */ public function error(mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->error($message); } @@ -61,7 +61,7 @@ class Logger implements LoggerInterface */ public function warning(mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->warning($message); } @@ -72,7 +72,7 @@ class Logger implements LoggerInterface */ public function notice(mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->info($message); } @@ -83,7 +83,7 @@ class Logger implements LoggerInterface */ public function info(mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->info($message); } @@ -95,7 +95,7 @@ class Logger implements LoggerInterface */ public function debug(mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->debug($message); } @@ -107,7 +107,7 @@ class Logger implements LoggerInterface */ public function log($level, mixed $message, array $context = array()) { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->debug($message); } diff --git a/Rpc/Actuator.php b/Rpc/Actuator.php index 1937607d..20ff5e72 100644 --- a/Rpc/Actuator.php +++ b/Rpc/Actuator.php @@ -6,7 +6,7 @@ namespace Rpc; use Exception; use HttpServer\Route\Router; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @@ -27,7 +27,7 @@ class Actuator */ public function __construct(public int $port) { - $this->router = Snowflake::getApp('router'); + $this->router = Kiri::getApp('router'); } diff --git a/Rpc/Client.php b/Rpc/Client.php index abb91947..12861cca 100644 --- a/Rpc/Client.php +++ b/Rpc/Client.php @@ -5,9 +5,9 @@ namespace Rpc; use Exception; -use Snowflake\Abstracts\Component; -use Snowflake\Channel; -use Snowflake\Core\Json; +use Kiri\Abstracts\Component; +use Kiri\Channel; +use Kiri\Core\Json; use Swoole\Coroutine\Client as CClient; diff --git a/Rpc/Consumer.php b/Rpc/Consumer.php index 78555c77..f6646598 100644 --- a/Rpc/Consumer.php +++ b/Rpc/Consumer.php @@ -6,7 +6,7 @@ namespace Rpc; use Annotation\Inject; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class Consumer @@ -46,7 +46,7 @@ abstract class Consumer implements IProducer if (method_exists($this, $method)) { return $this->{$method}(); } - return Snowflake::app()->get($name); + return Kiri::app()->get($name); } diff --git a/Rpc/Producer.php b/Rpc/Producer.php index 4c03d1a8..77d3e4ac 100644 --- a/Rpc/Producer.php +++ b/Rpc/Producer.php @@ -6,8 +6,8 @@ namespace Rpc; use Exception; use JetBrains\PhpStorm\ArrayShape; -use Snowflake\Abstracts\Component; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Kiri; /** @@ -126,11 +126,11 @@ class Producer extends Component if (!empty($host)) { $producer['host'] = $host; } else if (!isset($producer['host'])) { - $producer['host'] = Snowflake::localhost(); + $producer['host'] = Kiri::localhost(); } $producerName = $this->getName($name, $producer); - $snowflake = Snowflake::app(); + $snowflake = Kiri::app(); if (!$snowflake->has($producerName)) { return $snowflake->set($producerName, $this->definer($name, $producer)); } else { diff --git a/Rpc/Service.php b/Rpc/Service.php index 1b8a57d0..35dcaa5a 100644 --- a/Rpc/Service.php +++ b/Rpc/Service.php @@ -9,10 +9,10 @@ use HttpServer\Http\Context; use HttpServer\Route\Router; use Server\Constant; use Server\Events\OnAfterRequest; -use Snowflake\Core\Json; -use Snowflake\Events\EventDispatch; -use Snowflake\Events\EventProvider; -use Snowflake\Snowflake; +use Kiri\Core\Json; +use Kiri\Events\EventDispatch; +use Kiri\Events\EventProvider; +use Kiri\Kiri; use Swoole\Http\Request; use Swoole\Server; use function Swoole\Coroutine\defer; @@ -46,7 +46,7 @@ class Service extends \Server\Abstracts\Server */ public function init() { - $this->router = Snowflake::getApp('router'); + $this->router = Kiri::getApp('router'); } diff --git a/Rpc/config.php b/Rpc/config.php index 1c4a4b37..a05df00d 100644 --- a/Rpc/config.php +++ b/Rpc/config.php @@ -2,10 +2,10 @@ use HttpServer\Server; -use Snowflake\Snowflake; +use Kiri\Kiri; /** @var \HttpServer\Route\Router $router */ -$router = Snowflake::getApp('router'); +$router = Kiri::getApp('router'); $router->addRpcService(9527, function (\Rpc\Actuator $actuator) { $actuator->addListener('', ''); $actuator->addListener('', ''); diff --git a/Server/Abstracts/Server.php b/Server/Abstracts/Server.php index 89713759..58b8faba 100644 --- a/Server/Abstracts/Server.php +++ b/Server/Abstracts/Server.php @@ -6,10 +6,10 @@ namespace Server\Abstracts; use Closure; use Exception; -use Snowflake\Abstracts\Config; -use Snowflake\Event; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Event; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; use Swoole\Server\Port; @@ -34,7 +34,7 @@ abstract class Server */ protected function setProcessName($prefix) { - if (Snowflake::getPlatform()->isMac()) { + if (Kiri::getPlatform()->isMac()) { return; } $name = Config::get('id', 'system-service'); @@ -51,7 +51,7 @@ abstract class Server */ public function __construct() { - $this->_event = Snowflake::getApp('event'); + $this->_event = Kiri::getApp('event'); } @@ -63,7 +63,7 @@ abstract class Server public function setEvents(string $name, ?array $events): void { if (is_array($events) && is_string($events[0])) { - $events[0] = Snowflake::getDi()->get($events[0]); + $events[0] = Kiri::getDi()->get($events[0]); } if (!is_callable($events)) { return; diff --git a/Server/Constrict/Request.php b/Server/Constrict/Request.php index a2964564..8108ce36 100644 --- a/Server/Constrict/Request.php +++ b/Server/Constrict/Request.php @@ -9,9 +9,9 @@ use HttpServer\Http\Request as HttpResponse; use HttpServer\Http\Response; use ReflectionException; use Server\RequestInterface; -use Snowflake\Abstracts\BaseObject; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\BaseObject; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** @@ -72,6 +72,6 @@ class Request implements RequestInterface Context::setContext(HttpResponse::class, $sRequest); - return Snowflake::getDi()->get(Request::class); + return Kiri::getDi()->get(Request::class); } } diff --git a/Server/Constrict/ResponseEmitter.php b/Server/Constrict/ResponseEmitter.php index c91344bf..a6007bee 100644 --- a/Server/Constrict/ResponseEmitter.php +++ b/Server/Constrict/ResponseEmitter.php @@ -6,7 +6,7 @@ use Exception; use HttpServer\Http\Formatter\FileFormatter; use ReflectionException; use Server\ResponseInterface; -use Snowflake\Exception\NotFindClassException; +use Kiri\Exception\NotFindClassException; /** diff --git a/Server/HTTPServerListener.php b/Server/HTTPServerListener.php index 45f24e62..2aab1b40 100644 --- a/Server/HTTPServerListener.php +++ b/Server/HTTPServerListener.php @@ -12,11 +12,11 @@ use ReflectionException; use Server\Constrict\Response as CResponse; use Server\Constrict\ResponseEmitter; use Server\Events\OnAfterRequest; -use Snowflake\Abstracts\Config; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Events\EventDispatch; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use Swoole\Error; use Swoole\Http\Request; use Swoole\Http\Response; @@ -73,7 +73,7 @@ class HTTPServerListener extends Abstracts\Server if (!in_array(ExceptionHandlerInterface::class, class_implements($exceptionHandler))) { $exceptionHandler = ExceptionHandlerDispatcher::class; } - $this->exceptionHandler = Snowflake::getDi()->get($exceptionHandler); + $this->exceptionHandler = Kiri::getDi()->get($exceptionHandler); } diff --git a/Server/ListenerHelper.php b/Server/ListenerHelper.php index dec13985..d87f6e69 100644 --- a/Server/ListenerHelper.php +++ b/Server/ListenerHelper.php @@ -5,8 +5,8 @@ namespace Server; use Closure; use ReflectionException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; /** @@ -35,7 +35,7 @@ trait ListenerHelper if ($callback instanceof Closure) { return $callback; } - $object = Snowflake::getDi()->getReflect($callback[0]); + $object = Kiri::getDi()->getReflect($callback[0]); if ($object->getMethod($callback[1])->isStatic()) { return $callback; } diff --git a/Server/Manager/OnPipeMessage.php b/Server/Manager/OnPipeMessage.php index 4467ca49..fae4e8b1 100644 --- a/Server/Manager/OnPipeMessage.php +++ b/Server/Manager/OnPipeMessage.php @@ -9,7 +9,7 @@ use Server\Constant; use Exception; use Server\Events\OnAfterRequest; use Server\SInterface\PipeMessage; -use Snowflake\Events\EventDispatch; +use Kiri\Events\EventDispatch; /** * diff --git a/Server/Manager/OnServerDefault.php b/Server/Manager/OnServerDefault.php index ba923623..eb204f23 100644 --- a/Server/Manager/OnServerDefault.php +++ b/Server/Manager/OnServerDefault.php @@ -8,9 +8,9 @@ use Server\Abstracts\Server; use Server\Constant; use Server\Events\OnAfterRequest; use Server\SInterface\PipeMessage; -use Snowflake\Event; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\ConfigException; +use Kiri\Event; +use Kiri\Events\EventDispatch; +use Kiri\Exception\ConfigException; /** diff --git a/Server/Manager/OnServerManager.php b/Server/Manager/OnServerManager.php index a85d7dd8..dec337f9 100644 --- a/Server/Manager/OnServerManager.php +++ b/Server/Manager/OnServerManager.php @@ -4,7 +4,7 @@ namespace Server\Manager; use Server\Abstracts\Server; use Server\Constant; -use Snowflake\Exception\ConfigException; +use Kiri\Exception\ConfigException; /** diff --git a/Server/ServerManager.php b/Server/ServerManager.php index b3937711..d2be4d22 100644 --- a/Server/ServerManager.php +++ b/Server/ServerManager.php @@ -9,10 +9,10 @@ use Server\Manager\OnPipeMessage; use Server\SInterface\CustomProcess; use Server\SInterface\TaskExecute; use Server\Task\OnServerTask; -use Snowflake\Abstracts\Config; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use Swoole\Http\Server as HServer; use Swoole\Process; use Swoole\Server; @@ -113,7 +113,7 @@ class ServerManager extends Abstracts\Server */ private function checkPort($port): bool { - if (Snowflake::getPlatform()->isLinux()) { + if (Kiri::getPlatform()->isLinux()) { exec('netstat -tunlp | grep ' . $port, $output); } else { exec('lsof -i :' . $port . ' | grep -i "LISTEN"', $output); @@ -141,7 +141,7 @@ class ServerManager extends Abstracts\Server /** @var Process $process */ $this->server->addProcess(new Process(function (Process $soloProcess) use ($customProcess) { $system = sprintf('%s.process[%d]', Config::get('id', 'system-service'), $soloProcess->pid); - if (Snowflake::getPlatform()->isLinux()) { + if (Kiri::getPlatform()->isLinux()) { $soloProcess->name($system . '.' . $customProcess->getProcessName($soloProcess) . ' start.'); } @@ -241,10 +241,10 @@ class ServerManager extends Abstracts\Server } $this->ports[$port]->set($settings['settings'] ?? []); $reflect = match ($type) { - Constant::SERVER_TYPE_TCP => Snowflake::getDi()->newObject(TCPServerListener::class), - Constant::SERVER_TYPE_UDP => Snowflake::getDi()->newObject(UDPServerListener::class), - Constant::SERVER_TYPE_HTTP => Snowflake::getDi()->newObject(HTTPServerListener::class), - Constant::SERVER_TYPE_WEBSOCKET => Snowflake::getDi()->newObject(WebSocketServerListener::class), + Constant::SERVER_TYPE_TCP => Kiri::getDi()->newObject(TCPServerListener::class), + Constant::SERVER_TYPE_UDP => Kiri::getDi()->newObject(UDPServerListener::class), + Constant::SERVER_TYPE_HTTP => Kiri::getDi()->newObject(HTTPServerListener::class), + Constant::SERVER_TYPE_WEBSOCKET => Kiri::getDi()->newObject(WebSocketServerListener::class), default => throw new Exception(''), }; $reflect->bindCallback($this->ports[$port], $settings['events'] ?? []); @@ -372,7 +372,7 @@ class ServerManager extends Abstracts\Server */ private function getNewInstance(string $class): object { - return Snowflake::getDi()->newObject($class); + return Kiri::getDi()->newObject($class); } @@ -389,7 +389,7 @@ class ServerManager extends Abstracts\Server $this->server->setting['worker_num'] + 1 + $this->server->setting['task_worker_num']); } if (is_string($handler)) { - $implements = Snowflake::getDi()->getReflect($handler); + $implements = Kiri::getDi()->getReflect($handler); if (!in_array(TaskExecute::class, $implements->getInterfaceNames())) { throw new Exception('Task must instance ' . TaskExecute::class); } @@ -406,7 +406,7 @@ class ServerManager extends Abstracts\Server private function addTaskListener(array $events = []): void { $task_use_object = $this->server->setting['task_object'] ?? $this->server->setting['task_use_object'] ?? false; - $reflect = Snowflake::getDi()->getReflect(OnServerTask::class)?->newInstance(); + $reflect = Kiri::getDi()->getReflect(OnServerTask::class)?->newInstance(); if ($task_use_object || $this->server->setting['task_enable_coroutine']) { $this->server->on('task', $events[Constant::TASK] ?? [$reflect, 'onCoroutineTask']); } else { @@ -433,7 +433,7 @@ class ServerManager extends Abstracts\Server continue; } if (is_array($callback) && !is_object($callback[0])) { - $callback[0] = Snowflake::getDi()->get($callback[0]); + $callback[0] = Kiri::getDi()->get($callback[0]); } $this->server->on($event_type, $callback); } diff --git a/Server/TCPServerListener.php b/Server/TCPServerListener.php index 8323792f..298f2148 100644 --- a/Server/TCPServerListener.php +++ b/Server/TCPServerListener.php @@ -5,8 +5,8 @@ namespace Server; use Annotation\Inject; use Exception; use Server\Events\OnAfterRequest; -use Snowflake\Event; -use Snowflake\Events\EventDispatch; +use Kiri\Event; +use Kiri\Events\EventDispatch; use Swoole\Server; use Swoole\Server\Port; diff --git a/Server/Task/OnServerTask.php b/Server/Task/OnServerTask.php index e6d8abc3..569acb13 100644 --- a/Server/Task/OnServerTask.php +++ b/Server/Task/OnServerTask.php @@ -6,8 +6,8 @@ namespace Server\Task; use ReflectionException; use Server\SInterface\TaskExecute; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use Swoole\Server; @@ -63,7 +63,7 @@ class OnServerTask { [$class, $params] = json_encode($data, true); - $reflect = Snowflake::getDi()->getReflect($class); + $reflect = Kiri::getDi()->getReflect($class); if (!$reflect->isInstantiable()) { return null; diff --git a/Server/UDPServerListener.php b/Server/UDPServerListener.php index 7286509b..4366e11d 100644 --- a/Server/UDPServerListener.php +++ b/Server/UDPServerListener.php @@ -6,9 +6,9 @@ use Annotation\Inject; use Exception; use ReflectionException; use Server\Events\OnAfterRequest; -use Snowflake\Event; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\NotFindClassException; +use Kiri\Event; +use Kiri\Events\EventDispatch; +use Kiri\Exception\NotFindClassException; use Swoole\Server; use Swoole\Server\Port; diff --git a/Server/WebSocketServerListener.php b/Server/WebSocketServerListener.php index 80ed3fb8..745ad57d 100644 --- a/Server/WebSocketServerListener.php +++ b/Server/WebSocketServerListener.php @@ -6,9 +6,9 @@ use Annotation\Inject; use Exception; use ReflectionException; use Server\Events\OnAfterRequest; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Events\EventDispatch; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use Swoole\Http\Request; use Swoole\Http\Response; use Swoole\Server; @@ -60,7 +60,7 @@ class WebSocketServerListener extends Abstracts\Server $events = $settings['events'][Constant::REQUEST] ?? []; if (!empty($events) && is_array($events)) { - $events[0] = Snowflake::getDi()->get($events[0]); + $events[0] = Kiri::getDi()->get($events[0]); $server->on('request', $events); } return $server; diff --git a/Server/Worker/OnServerWorker.php b/Server/Worker/OnServerWorker.php index a8f38005..6347c704 100644 --- a/Server/Worker/OnServerWorker.php +++ b/Server/Worker/OnServerWorker.php @@ -12,13 +12,13 @@ use Server\Events\OnWorkerError; use Server\Events\OnWorkerExit; use Server\Events\OnWorkerStart; use Server\Events\OnWorkerStop; -use Snowflake\Abstracts\Config; -use Snowflake\Core\Help; -use Snowflake\Events\EventDispatch; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Runtime; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Core\Help; +use Kiri\Events\EventDispatch; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Runtime; +use Kiri\Kiri; use Swoole\Server; use Swoole\Timer; @@ -46,7 +46,7 @@ class OnServerWorker extends \Server\Abstracts\Server public function onWorkerStart(Server $server, int $workerId) { $this->_setConfigCache($workerId); - $annotation = Snowflake::app()->getAnnotation(); + $annotation = Kiri::app()->getAnnotation(); $annotation->read(APP_PATH . 'app', 'App', $workerId < $server->setting['worker_num'] ? [] : [CONTROLLER_PATH] ); @@ -71,7 +71,7 @@ class OnServerWorker extends \Server\Abstracts\Server private function interpretDirectory(Annotation $annotation) { $fileLists = $annotation->runtime(APP_PATH . 'app'); - $di = Snowflake::getDi(); + $di = Kiri::getDi(); foreach ($fileLists as $class) { $instance = $di->get($class); foreach ($di->getTargetNote($class) as $value) { @@ -100,15 +100,15 @@ class OnServerWorker extends \Server\Abstracts\Server private function workerInitExecutor(Server $server, Annotation $annotation, int $workerId) { if ($workerId < $server->setting['worker_num']) { - $loader = Snowflake::app()->getRouter(); + $loader = Kiri::app()->getRouter(); $loader->_loader(); - putenv('environmental=' . Snowflake::WORKER); + putenv('environmental=' . Kiri::WORKER); echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m Worker[%d].%d start.", $server->worker_pid, $workerId) . PHP_EOL; $this->setProcessName(sprintf('Worker[%d].%d', $server->worker_pid, $workerId)); } else { - putenv('environmental=' . Snowflake::TASK); + putenv('environmental=' . Kiri::TASK); echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m Tasker[%d].%d start.", $server->worker_pid, $workerId) . PHP_EOL; @@ -162,7 +162,7 @@ class OnServerWorker extends \Server\Abstracts\Server $this->eventDispatch->dispatch(new OnWorkerExit($server, $workerId)); - Snowflake::getApp('logger')->insert(); + Kiri::getApp('logger')->insert(); } diff --git a/System/Abstracts/BaseApplication.php b/System/Abstracts/BaseApplication.php index 8949eb59..83a27051 100644 --- a/System/Abstracts/BaseApplication.php +++ b/System/Abstracts/BaseApplication.php @@ -7,7 +7,7 @@ */ declare(strict_types=1); -namespace Snowflake\Abstracts; +namespace Kiri\Abstracts; use Annotation\Annotation as SAnnotation; @@ -28,22 +28,22 @@ use ReflectionException; use Rpc\Producer; use Rpc\Service; use Server\ServerManager; -use Snowflake\Aop; -use Snowflake\Async; -use Snowflake\Cache\Redis; -use Snowflake\Di\LocalService; -use Snowflake\Error\ErrorHandler; -use Snowflake\Error\Logger; -use Snowflake\Event; -use Snowflake\Exception\InitException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Jwt\Jwt; -use Snowflake\Snowflake; +use Kiri\Aop; +use Kiri\Async; +use Kiri\Cache\Redis; +use Kiri\Di\LocalService; +use Kiri\Error\ErrorHandler; +use Kiri\Error\Logger; +use Kiri\Event; +use Kiri\Exception\InitException; +use Kiri\Exception\NotFindClassException; +use Kiri\Jwt\Jwt; +use Kiri\Kiri; use Swoole\Table; /** * Class BaseApplication - * @package Snowflake\Snowflake\Base + * @package Kiri\Kiri\Base */ abstract class BaseApplication extends Component { @@ -66,7 +66,7 @@ abstract class BaseApplication extends Component */ public function __construct() { - Snowflake::init($this); + Kiri::init($this); $config = sweep(APP_PATH . '/config'); @@ -170,7 +170,7 @@ abstract class BaseApplication extends Component * @param $name * @return mixed * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException + * @throws \Kiri\Exception\NotFindClassException */ public function __get($name): mixed { @@ -193,7 +193,7 @@ abstract class BaseApplication extends Component } foreach ($config['events'] as $key => $value) { if (is_string($value)) { - $value = Snowflake::createObject($value); + $value = Kiri::createObject($value); } $this->addEvent($key, $value); } @@ -225,7 +225,7 @@ abstract class BaseApplication extends Component } if (is_string($value[0])) { - $value[0] = Snowflake::createObject($value[0]); + $value[0] = Kiri::createObject($value[0]); Event::on($key, $value, true); return; } @@ -265,7 +265,7 @@ abstract class BaseApplication extends Component * @param $name * @return mixed * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException + * @throws \Kiri\Exception\NotFindClassException */ public function get($name): mixed { @@ -422,7 +422,7 @@ abstract class BaseApplication extends Component /** * @param $array * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException + * @throws \Kiri\Exception\NotFindClassException */ private function setComponents($array): void { @@ -434,7 +434,7 @@ abstract class BaseApplication extends Component * @param $id * @param $definition * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException + * @throws \Kiri\Exception\NotFindClassException */ public function set($id, $definition): void { @@ -446,7 +446,7 @@ abstract class BaseApplication extends Component * @param $id * @param $definition * @throws \ReflectionException - * @throws \Snowflake\Exception\NotFindClassException + * @throws \Kiri\Exception\NotFindClassException */ public function has($id): bool { diff --git a/System/Abstracts/BaseGoto.php b/System/Abstracts/BaseGoto.php index d45eda5b..edabb8cc 100644 --- a/System/Abstracts/BaseGoto.php +++ b/System/Abstracts/BaseGoto.php @@ -1,16 +1,16 @@ getLogger(); + return Kiri::app()->getLogger(); } diff --git a/System/Abstracts/Command.php b/System/Abstracts/Command.php index 29ebf138..881612b3 100644 --- a/System/Abstracts/Command.php +++ b/System/Abstracts/Command.php @@ -1,7 +1,7 @@ getConfig(); + $config = Kiri::app()->getConfig(); if (empty($configs)) { return; } @@ -68,7 +68,7 @@ class Config extends Component */ public static function get($key, mixed $default = null, bool $try = FALSE): mixed { - $instance = Snowflake::app()->getConfig()->getData(); + $instance = Kiri::app()->getConfig()->getData(); if (!str_contains($key, '.')) { return $instance[$key] ?? $default; } @@ -98,7 +98,7 @@ class Config extends Component */ public static function set($key, $value): mixed { - $config = Snowflake::app()->getConfig(); + $config = Kiri::app()->getConfig(); return $config->setData($key, $value); } @@ -110,7 +110,7 @@ class Config extends Component */ public static function has($key, bool $must_not_null = false): bool { - $config = Snowflake::app()->getConfig(); + $config = Kiri::app()->getConfig(); if (!isset($config->data[$key])) { return false; } diff --git a/System/Abstracts/Configure.php b/System/Abstracts/Configure.php index 4ec40b5c..a7f4d8c6 100644 --- a/System/Abstracts/Configure.php +++ b/System/Abstracts/Configure.php @@ -6,11 +6,11 @@ * Time: 14:11 */ declare(strict_types=1); -namespace Snowflake\Abstracts; +namespace Kiri\Abstracts; /** * Interface Configure - * @package Snowflake\Snowflake\Base + * @package Kiri\Kiri\Base */ interface Configure { diff --git a/System/Abstracts/IListener.php b/System/Abstracts/IListener.php index 8efc1625..fad1689c 100644 --- a/System/Abstracts/IListener.php +++ b/System/Abstracts/IListener.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Snowflake\Abstracts; +namespace Kiri\Abstracts; -use Snowflake\Core\Dtl; +use Kiri\Core\Dtl; /** * Interface IListener - * @package Snowflake\Abstracts + * @package Kiri\Abstracts */ interface IListener { diff --git a/System/Abstracts/Input.php b/System/Abstracts/Input.php index d249dd32..205f726a 100644 --- a/System/Abstracts/Input.php +++ b/System/Abstracts/Input.php @@ -1,7 +1,7 @@ getReflect(current(static::$_aop[$aopName])); + $reflect = Kiri::getDi()->getReflect(current(static::$_aop[$aopName])); if (!$reflect->isInstantiable() || !$reflect->hasMethod('invoke')) { throw new Exception(ASPECT_ERROR . IAspect::class); } @@ -81,7 +81,7 @@ class Aop extends Component { $aopName = $handler[0]::class . '::' . $handler[1]; - $reflect = Snowflake::getDi()->get(current(static::$_aop[$aopName])); + $reflect = Kiri::getDi()->get(current(static::$_aop[$aopName])); if (!method_exists($reflect, 'invoke')) { throw new Exception(ASPECT_ERROR . IAspect::class); } diff --git a/System/Application.php b/System/Application.php index 941f5ae2..ff833eae 100644 --- a/System/Application.php +++ b/System/Application.php @@ -7,7 +7,7 @@ */ declare(strict_types=1); -namespace Snowflake; +namespace Kiri; use Closure; @@ -18,19 +18,19 @@ use Exception; use HttpServer\Command; use HttpServer\Http\Response; use HttpServer\ServerProviders; -use Snowflake\Abstracts\BaseApplication; -use Snowflake\Abstracts\Config; -use Snowflake\Abstracts\Input; -use Snowflake\Abstracts\Kernel; -use Snowflake\Crontab\CrontabProviders; -use Snowflake\Exception\NotFindClassException; +use Kiri\Abstracts\BaseApplication; +use Kiri\Abstracts\Config; +use Kiri\Abstracts\Input; +use Kiri\Abstracts\Kernel; +use Kiri\Crontab\CrontabProviders; +use Kiri\Exception\NotFindClassException; use stdClass; use Swoole\Timer; /** * Class Init * - * @package Snowflake + * @package Kiri * * @property-read Config $config */ @@ -96,7 +96,7 @@ class Application extends BaseApplication if (!class_exists($service)) { throw new NotFindClassException($service); } - $class = Snowflake::getDi()->get($service); + $class = Kiri::getDi()->get($service); if (method_exists($class, 'onImport')) { $class->onImport($this); } @@ -138,7 +138,7 @@ class Application extends BaseApplication { try { /** @var Console $manager */ - $manager = Snowflake::app()->get('console'); + $manager = Kiri::app()->get('console'); $manager->register(Runtime::class); $class = $manager->setParameters($argv)->search(); if (!($class instanceof Command)) { diff --git a/System/Async.php b/System/Async.php index 2a326682..17c5d6e6 100644 --- a/System/Async.php +++ b/System/Async.php @@ -1,17 +1,17 @@ getSwoole(); + $server = Kiri::app()->getSwoole(); if (!isset($server->setting['task_worker_num'])) { return; } @@ -47,7 +47,7 @@ class Async extends Component } /** @var Task $class */ - $class = Snowflake::createObject(static::$_absences[$name]); + $class = Kiri::createObject(static::$_absences[$name]); $class->setParams($params); $randWorkerId = random_int(0, $server->setting['task_worker_num'] - 1); diff --git a/System/Cache/File.php b/System/Cache/File.php index af3a9766..2c5c6f40 100644 --- a/System/Cache/File.php +++ b/System/Cache/File.php @@ -7,18 +7,18 @@ */ declare(strict_types=1); -namespace Snowflake\Cache; +namespace Kiri\Cache; use Exception; use JetBrains\PhpStorm\Pure; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; use Swoole\Coroutine\System; /** * Class File - * @package Snowflake\Snowflake\Cache + * @package Kiri\Kiri\Cache */ class File extends Component implements ICache { diff --git a/System/Cache/ICache.php b/System/Cache/ICache.php index 8280ef65..43c57e49 100644 --- a/System/Cache/ICache.php +++ b/System/Cache/ICache.php @@ -7,11 +7,11 @@ */ declare(strict_types=1); -namespace Snowflake\Cache; +namespace Kiri\Cache; /** * Interface ICache - * @package Snowflake\Snowflake\Cache + * @package Kiri\Kiri\Cache */ interface ICache { diff --git a/System/Cache/Redis.php b/System/Cache/Redis.php index a694df3f..7b4c8190 100644 --- a/System/Cache/Redis.php +++ b/System/Cache/Redis.php @@ -7,23 +7,23 @@ */ declare(strict_types=1); -namespace Snowflake\Cache; +namespace Kiri\Cache; use Annotation\Inject; use Exception; use Server\Events\OnWorkerExit; use Server\Events\OnWorkerStop; -use Snowflake\Abstracts\Component; -use Snowflake\Abstracts\Config; -use Snowflake\Core\Json; -use Snowflake\Events\EventProvider; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; -use Snowflake\Pool\Redis as PoolRedis; +use Kiri\Abstracts\Component; +use Kiri\Abstracts\Config; +use Kiri\Core\Json; +use Kiri\Events\EventProvider; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; +use Kiri\Pool\Redis as PoolRedis; /** * Class Redis - * @package Snowflake\Snowflake\Cache + * @package Kiri\Kiri\Cache * @mixin \Redis */ class Redis extends Component @@ -42,7 +42,7 @@ class Redis extends Component */ public function init() { - $connections = Snowflake::getDi()->get(PoolRedis::class); + $connections = Kiri::getDi()->get(PoolRedis::class); $config = $this->get_config(); @@ -114,7 +114,7 @@ SCRIPT; */ public function release() { - $connections = Snowflake::getDi()->get(PoolRedis::class); + $connections = Kiri::getDi()->get(PoolRedis::class); $connections->release($this->get_config(), true); } @@ -125,7 +125,7 @@ SCRIPT; */ public function destroy() { - $connections = Snowflake::getDi()->get(PoolRedis::class); + $connections = Kiri::getDi()->get(PoolRedis::class); $connections->destroy($this->get_config(), true); } @@ -135,7 +135,7 @@ SCRIPT; */ public function proxy(): \Redis { - $connections = Snowflake::getDi()->get(PoolRedis::class); + $connections = Kiri::getDi()->get(PoolRedis::class); $config = $this->get_config(); diff --git a/System/Core/ArrayAccess.php b/System/Core/ArrayAccess.php index 4c03fd47..e5c4988c 100644 --- a/System/Core/ArrayAccess.php +++ b/System/Core/ArrayAccess.php @@ -7,14 +7,14 @@ */ declare(strict_types=1); -namespace Snowflake\Core; +namespace Kiri\Core; use Exception; /** * Class ArrayAccess - * @package Snowflake\Core + * @package Kiri\Core */ class ArrayAccess { diff --git a/System/Core/DateFormat.php b/System/Core/DateFormat.php index e7d71c39..de00dec4 100644 --- a/System/Core/DateFormat.php +++ b/System/Core/DateFormat.php @@ -7,13 +7,13 @@ */ declare(strict_types=1); -namespace Snowflake\Core; +namespace Kiri\Core; /** * Class DateFormat - * @package Snowflake\Snowflake\Core + * @package Kiri\Kiri\Core */ class DateFormat { diff --git a/System/Core/Dtl.php b/System/Core/Dtl.php index decdfb92..926e84f9 100644 --- a/System/Core/Dtl.php +++ b/System/Core/Dtl.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Snowflake\Core; +namespace Kiri\Core; use Exception; -use Snowflake\Abstracts\Component; +use Kiri\Abstracts\Component; /** * Class Dtl - * @package Snowflake\Core + * @package Kiri\Core */ class Dtl extends Component { diff --git a/System/Core/Help.php b/System/Core/Help.php index 0ca076f1..96a40ed9 100644 --- a/System/Core/Help.php +++ b/System/Core/Help.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Snowflake\Core; +namespace Kiri\Core; use Exception; @@ -10,7 +10,7 @@ use Exception; /** * Class Help - * @package Snowflake\Snowflake\Core + * @package Kiri\Kiri\Core */ class Help { diff --git a/System/Core/Json.php b/System/Core/Json.php index 96c136ec..769b63fa 100644 --- a/System/Core/Json.php +++ b/System/Core/Json.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Snowflake\Core; +namespace Kiri\Core; use Error; use Exception; @@ -16,7 +16,7 @@ use Throwable; /** * Class JSON - * @package Snowflake\Snowflake\Core + * @package Kiri\Kiri\Core */ class Json { diff --git a/System/Core/Number.php b/System/Core/Number.php index 7e1c69b1..2abbe09e 100644 --- a/System/Core/Number.php +++ b/System/Core/Number.php @@ -1,7 +1,7 @@ getRedis(); + $redis = Kiri::app()->getRedis(); $name = $crontab->getName(); if ($redis->exists(self::CRONTAB_KEY) && $redis->type(self::CRONTAB_KEY) !== \Redis::REDIS_ZSET) { @@ -48,7 +48,7 @@ class Producer extends Component */ public function clear(string $name) { - $redis = Snowflake::app()->getRedis(); + $redis = Kiri::app()->getRedis(); $redis->del('crontab:' . md5($name)); $redis->zRem(static::CRONTAB_KEY, md5($name)); @@ -64,7 +64,7 @@ class Producer extends Component */ public function exists(string $name): bool { - $redis = Snowflake::app()->getRedis(); + $redis = Kiri::app()->getRedis(); if ($redis->exists('crontab:' . md5($name))) { return true; } @@ -83,7 +83,7 @@ class Producer extends Component */ public function clearAll() { - $redis = Snowflake::app()->getRedis(); + $redis = Kiri::app()->getRedis(); $data = $redis->zRange(self::CRONTAB_KEY, 0, -1); foreach ($data as $datum) { $redis->setex('stop:crontab:' . $datum, 120, 1); diff --git a/System/Crontab/Zookeeper.php b/System/Crontab/Zookeeper.php index b04e1ee8..301d7e8f 100644 --- a/System/Crontab/Zookeeper.php +++ b/System/Crontab/Zookeeper.php @@ -1,23 +1,23 @@ getRedis(); + $redis = Kiri::app()->getRedis(); defer(fn() => $redis->release()); $range = $this->loadCarobTask($redis); foreach ($range as $value) { diff --git a/System/Di/Attributes.php b/System/Di/Attributes.php index 350f8363..1d617cd7 100644 --- a/System/Di/Attributes.php +++ b/System/Di/Attributes.php @@ -1,6 +1,6 @@ getType()->getName(); if (is_string($type) && class_exists($type)) { - $type = Snowflake::getDi()->get($type); + $type = Kiri::getDi()->get($type); } $params[$key] = match ($parameter->getType()) { 'string' => '', diff --git a/System/Di/LocalService.php b/System/Di/LocalService.php index ddf39719..92c8d283 100644 --- a/System/Di/LocalService.php +++ b/System/Di/LocalService.php @@ -1,10 +1,10 @@ _components[$name] = $definition; } - return $this->_components[$name] = Snowflake::createObject($definition); + return $this->_components[$name] = Kiri::createObject($definition); } else if ($throwException) { throw new \Exception("Unknown component ID: $name"); } diff --git a/System/Environmental.php b/System/Environmental.php index 70a6c45c..f8b431bf 100644 --- a/System/Environmental.php +++ b/System/Environmental.php @@ -1,7 +1,7 @@ error($data, 'error'); + Kiri::app()->error($data, 'error'); Event::trigger(Event::SYSTEM_RESOURCE_CLEAN); @@ -149,6 +149,6 @@ class ErrorHandler extends Component implements ErrorInterface */ public function writer($message, string $category = 'app') { - Snowflake::app()->debug($message, $category); + Kiri::app()->debug($message, $category); } } diff --git a/System/Error/ErrorInterface.php b/System/Error/ErrorInterface.php index f596bdcb..9b052086 100644 --- a/System/Error/ErrorInterface.php +++ b/System/Error/ErrorInterface.php @@ -7,11 +7,11 @@ */ declare(strict_types=1); -namespace Snowflake\Error; +namespace Kiri\Error; /** * Interface ErrorInterface - * @package Snowflake\Snowflake\Error + * @package Kiri\Kiri\Error */ interface ErrorInterface { diff --git a/System/Error/Logger.php b/System/Error/Logger.php index 6f00720a..7894fc32 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -7,23 +7,23 @@ */ declare(strict_types=1); -namespace Snowflake\Error; +namespace Kiri\Error; use Annotation\Inject; use Exception; use Server\Events\OnAfterRequest; -use Snowflake\Abstracts\Component; -use Snowflake\Abstracts\Config; -use Snowflake\Core\Json; -use Snowflake\Events\EventProvider; -use Snowflake\Exception\ConfigException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Abstracts\Config; +use Kiri\Core\Json; +use Kiri\Events\EventProvider; +use Kiri\Exception\ConfigException; +use Kiri\Kiri; use Swoole\Coroutine; use Throwable; /** * Class Logger - * @package Snowflake\Snowflake\Error + * @package Kiri\Kiri\Error */ class Logger extends Component { @@ -263,7 +263,7 @@ class Logger extends Component { $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->write(jTraceEx($exception), 'exception'); return Json::to($code, $exception->getMessage(), [ diff --git a/System/Error/LoggerAspect.php b/System/Error/LoggerAspect.php index 5393b594..c4bd2980 100644 --- a/System/Error/LoggerAspect.php +++ b/System/Error/LoggerAspect.php @@ -1,15 +1,15 @@ read()); if (!empty($message)) { - Snowflake::writeFile($this->getDirName($message), $message[0], FILE_APPEND); + Kiri::writeFile($this->getDirName($message), $message[0], FILE_APPEND); $this->checkLogFile($message[1]); } diff --git a/System/Event.php b/System/Event.php index feda3cc5..e6d736b3 100644 --- a/System/Event.php +++ b/System/Event.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Snowflake; +namespace Kiri; use Exception; -use Snowflake\Abstracts\BaseObject; +use Kiri\Abstracts\BaseObject; use Swoole\Coroutine; /** * Class Event - * @package Snowflake + * @package Kiri */ class Event extends BaseObject { diff --git a/System/Events/EventDispatch.php b/System/Events/EventDispatch.php index 8716b799..f3f36a23 100644 --- a/System/Events/EventDispatch.php +++ b/System/Events/EventDispatch.php @@ -1,9 +1,9 @@ getJwt(); + $jwt = Kiri::app()->getJwt(); if (!$jwt->validator($authorization)) { throw new JWTAuthTokenException('JWT Validator fail.'); } diff --git a/System/Jwt/JWTAuthTokenException.php b/System/Jwt/JWTAuthTokenException.php index df91a304..ac1022c8 100644 --- a/System/Jwt/JWTAuthTokenException.php +++ b/System/Jwt/JWTAuthTokenException.php @@ -1,6 +1,6 @@ get(Pool::class); + return Kiri::getDi()->get(Pool::class); } } diff --git a/System/Pool/Pool.php b/System/Pool/Pool.php index 24f84d26..920ca8a3 100644 --- a/System/Pool/Pool.php +++ b/System/Pool/Pool.php @@ -1,15 +1,15 @@ creates); - if (Snowflake::isWorker() || Snowflake::isTask()) { + if (Kiri::isWorker() || Kiri::isTask()) { $this->debug('Worker #' . env('worker') . ' clear time tick.'); } $this->creates = -1; @@ -206,7 +206,7 @@ class Pool extends Component /** * @param $name * @return bool - * @throws \Snowflake\Exception\ConfigException + * @throws \Kiri\Exception\ConfigException */ public function isNull($name): bool { diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index af6708c4..748c30e3 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -2,22 +2,22 @@ declare(strict_types=1); -namespace Snowflake\Pool; +namespace Kiri\Pool; use Exception; use HttpServer\Http\Context; use Redis as SRedis; -use Snowflake\Abstracts\Component; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\RedisConnectException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Component; +use Kiri\Exception\ConfigException; +use Kiri\Exception\RedisConnectException; +use Kiri\Kiri; use Swoole\Coroutine; use Swoole\Runtime; /** * Class RedisClient - * @package Snowflake\Snowflake\Pool + * @package Kiri\Kiri\Pool */ class Redis extends Component { @@ -112,7 +112,7 @@ class Redis extends Component */ public function getPool(): Pool { - return Snowflake::getDi()->get(Pool::class); + return Kiri::getDi()->get(Pool::class); } diff --git a/System/Process/Biomonitoring.php b/System/Process/Biomonitoring.php index 0c23c14d..11ec186a 100644 --- a/System/Process/Biomonitoring.php +++ b/System/Process/Biomonitoring.php @@ -1,13 +1,13 @@ getSwoole(); + $server = Kiri::app()->getSwoole(); Timer::tick(1000, function () use ($server) { clearstatcache(); if (filesize($server->setting['log_file']) > 1024000000) { diff --git a/System/Process/ISystem.php b/System/Process/ISystem.php index 1bb01ca8..f2834507 100644 --- a/System/Process/ISystem.php +++ b/System/Process/ISystem.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Snowflake\Process; +namespace Kiri\Process; interface ISystem diff --git a/System/Process/Process.php b/System/Process/Process.php index 4c32a6ef..b937f9e3 100644 --- a/System/Process/Process.php +++ b/System/Process/Process.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace Snowflake\Process; +namespace Kiri\Process; use Exception; use JetBrains\PhpStorm\Pure; -use Snowflake\Event; -use Snowflake\Snowflake; +use Kiri\Event; +use Kiri\Kiri; /** * Class Process - * @package Snowflake\Snowflake\Service + * @package Kiri\Kiri\Service */ abstract class Process extends \Swoole\Process implements SProcess { @@ -36,12 +36,12 @@ abstract class Process extends \Swoole\Process implements SProcess */ public function _load(Process $process) { - Snowflake::setProcessId($this->pid); + Kiri::setProcessId($this->pid); - putenv('environmental=' . Snowflake::PROCESS); + putenv('environmental=' . Kiri::PROCESS); fire(Event::SERVER_WORKER_START); - if (Snowflake::getPlatform()->isLinux()) { + if (Kiri::getPlatform()->isLinux()) { name($this->pid, $this->getProcessName()); } if (method_exists($this, 'before')) { diff --git a/System/Process/SProcess.php b/System/Process/SProcess.php index da003d5d..1a2e26eb 100644 --- a/System/Process/SProcess.php +++ b/System/Process/SProcess.php @@ -1,7 +1,7 @@ getAnnotation(); + $annotation = Kiri::app()->getAnnotation(); $runtime = storage(static::CACHE_NAME); $config = storage(static::CONFIG_NAME); - Snowflake::writeFile($config, $this->configEach()); - Snowflake::writeFile($runtime, serialize($annotation->getLoader())); + Kiri::writeFile($config, $this->configEach()); + Kiri::writeFile($runtime, serialize($annotation->getLoader())); return 'ok'; } @@ -53,7 +53,7 @@ class Runtime extends Command public function configEach(): string { $array = []; - $configs = Snowflake::app()->getConfig(); + $configs = Kiri::app()->getConfig(); foreach ($configs->getData() as $key => $datum) { if ($datum instanceof \Closure) { continue; diff --git a/System/Snowflake.php b/System/Snowflake.php index e3642370..d4cd834b 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Snowflake; +namespace Kiri; use Annotation\Annotation; @@ -13,11 +13,11 @@ use HttpServer\IInterface\Task; use JetBrains\PhpStorm\Pure; use ReflectionException; use ReflectionProperty; -use Snowflake\Abstracts\Config; -use Snowflake\Core\Json; -use Snowflake\Di\Container; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Process\Process; +use Kiri\Abstracts\Config; +use Kiri\Core\Json; +use Kiri\Di\Container; +use Kiri\Exception\NotFindClassException; +use Kiri\Process\Process; use Swoole\Coroutine; use Swoole\WebSocket\Server; @@ -37,10 +37,10 @@ defined('SOCKET_PATH') or define('SOCKET_PATH', APP_PATH . 'app/Websocket/'); /** - * Class Snowflake - * @package Snowflake + * Class Kiri + * @package Kiri */ -class Snowflake +class Kiri { /** @var Container */ @@ -149,7 +149,7 @@ class Snowflake if (empty($port)) { return false; } - if (Snowflake::getPlatform()->isLinux()) { + if (Kiri::getPlatform()->isLinux()) { exec('netstat -tunlp | grep ' . $port, $output); } else { exec('lsof -i :' . $port . ' | grep -i "LISTEN"', $output); @@ -411,7 +411,7 @@ class Snowflake */ public static function getMasterPid(): bool|string { - $pid = Snowflake::app()->getSwoole()->setting['pid_file']; + $pid = Kiri::app()->getSwoole()->setting['pid_file']; return file_get_contents($pid); } @@ -527,7 +527,7 @@ class Snowflake */ public static function getPlatform(): Environmental { - return Snowflake::createObject(Environmental::class); + return Kiri::createObject(Environmental::class); } @@ -537,7 +537,7 @@ class Snowflake */ public static function reload(): mixed { - return Snowflake::app()->getSwoole()->reload(); + return Kiri::app()->getSwoole()->reload(); } @@ -634,5 +634,5 @@ class Snowflake } -//spl_autoload_register([Snowflake::class, 'autoload'], true, true); -Snowflake::$container = new Container(); +//spl_autoload_register([Kiri::class, 'autoload'], true, true); +Kiri::$container = new Container(); diff --git a/Validator/Validator.php b/Validator/Validator.php index dba43ff8..b04c386b 100644 --- a/Validator/Validator.php +++ b/Validator/Validator.php @@ -7,7 +7,7 @@ namespace validator; use Closure; use Exception; -use Snowflake\Snowflake; +use Kiri\Kiri; /** * Class Validator @@ -172,7 +172,7 @@ class Validator extends BaseValidator $constr = array_merge($this->classMap[$type], $define); /** @var BaseValidator $class */ - $class = Snowflake::createObject($constr); + $class = Kiri::createObject($constr); $class->setParams($param); $class->setModel($model); diff --git a/composer.json b/composer.json index 006b0529..934e3a70 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ "license": "MIT", "require": { "php": ">=8.0", - "swoole/ide-helper": "@dev", "ext-json": "*", "ext-fileinfo": "*", "ext-pdo": "*", @@ -34,7 +33,7 @@ }, "autoload": { "psr-4": { - "Snowflake\\": "System/", + "Kiri\\": "System/", "HttpServer\\": "HttpServer/", "Server\\": "Server/", "validator\\": "Validator/", diff --git a/function.php b/function.php index ee59ee01..6a95bd1f 100644 --- a/function.php +++ b/function.php @@ -11,15 +11,15 @@ use HttpServer\Http\Response as HttpResponse; use HttpServer\Route\Router; use JetBrains\PhpStorm\Pure; use Server\Constrict\Response; -use Snowflake\Abstracts\Config; -use Snowflake\Aop; -use Snowflake\Application; -use Snowflake\Core\ArrayAccess; -use Snowflake\Error\Logger; -use Snowflake\Event; -use Snowflake\Exception\ConfigException; -use Snowflake\Exception\NotFindClassException; -use Snowflake\Snowflake; +use Kiri\Abstracts\Config; +use Kiri\Aop; +use Kiri\Application; +use Kiri\Core\ArrayAccess; +use Kiri\Error\Logger; +use Kiri\Event; +use Kiri\Exception\ConfigException; +use Kiri\Exception\NotFindClassException; +use Kiri\Kiri; use Swoole\WebSocket\Server; if (!function_exists('make')) { @@ -34,18 +34,18 @@ if (!function_exists('make')) { function make($name, $default = null): mixed { if (class_exists($name)) { - return Snowflake::createObject($name); + return Kiri::createObject($name); } - if (Snowflake::has($name)) { - return Snowflake::app()->get($name); + if (Kiri::has($name)) { + return Kiri::app()->get($name); } if (empty($default)) { throw new Exception("Unknown component ID: $name"); } - if (Snowflake::has($default)) { - return Snowflake::app()->get($default); + if (Kiri::has($default)) { + return Kiri::app()->get($default); } - $class = Snowflake::createObject($default); + $class = Kiri::createObject($default); class_alias($name, $default, true); return $class; } @@ -62,7 +62,7 @@ if (!function_exists('workerName')) { */ function workerName($worker_id) { - return $worker_id >= Snowflake::app()->getSwoole()->setting['worker_num'] ? 'Task' : 'Worker'; + return $worker_id >= Kiri::app()->getSwoole()->setting['worker_num'] ? 'Task' : 'Worker'; } } @@ -77,7 +77,7 @@ if (!function_exists('annotation')) { */ function annotation(): Annotation { - return Snowflake::getAnnotation(); + return Kiri::getAnnotation(); } @@ -97,7 +97,7 @@ if (!function_exists('scan_directory')) { */ function scan_directory($dir, $namespace, array $exclude = []) { - $annotation = Snowflake::app()->getAnnotation(); + $annotation = Kiri::app()->getAnnotation(); $annotation->read($dir, $namespace, $exclude); injectRuntime($dir, $exclude); @@ -118,8 +118,8 @@ if (!function_exists('injectRuntime')) { */ function injectRuntime(string $path, array $exclude = []) { - $fileLists = Snowflake::getAnnotation()->runtime($path, $exclude); - $di = Snowflake::getDi(); + $fileLists = Kiri::getAnnotation()->runtime($path, $exclude); + $di = Kiri::getDi(); foreach ($fileLists as $class) { $instance = $di->get($class); foreach ($di->getTargetNote($class) as $value) { @@ -149,7 +149,7 @@ if (!function_exists('swoole')) { */ function swoole(): ?Server { - return Snowflake::getWebSocket(); + return Kiri::getWebSocket(); } @@ -293,7 +293,7 @@ if (!function_exists('loadByDir')) { $first = explode(DIRECTORY_SEPARATOR, $replace); array_shift($first); - Snowflake::setAutoload($namespace . '\\' . implode('\\', $first), $value); + Kiri::setAutoload($namespace . '\\' . implode('\\', $first), $value); } } } @@ -312,7 +312,7 @@ if (!function_exists('write')) { */ function write(string $messages, string $category = 'app') { - $logger = Snowflake::app()->getLogger(); + $logger = Kiri::app()->getLogger(); $logger->write($messages, $category); } } @@ -322,12 +322,12 @@ if (!function_exists('redis')) { /** - * @return \Snowflake\Cache\Redis|Redis + * @return \Kiri\Cache\Redis|Redis * @throws Exception */ - function redis(): \Snowflake\Cache\Redis|Redis + function redis(): \Kiri\Cache\Redis|Redis { - return Snowflake::app()->getRedis(); + return Kiri::app()->getRedis(); } } @@ -357,7 +357,7 @@ if (!function_exists('aop')) { */ function aop(mixed $handler, array $params = []): mixed { - return Snowflake::getDi()->get(Aop::class)->dispatch($handler, $params); + return Kiri::getDi()->get(Aop::class)->dispatch($handler, $params); } } @@ -370,7 +370,7 @@ if (!function_exists('app')) { */ #[Pure] function app(): ?Application { - return Snowflake::app(); + return Kiri::app(); } } @@ -413,7 +413,7 @@ if (!function_exists('logger')) { */ function logger(): Logger { - return Snowflake::app()->getLogger(); + return Kiri::app()->getLogger(); } } @@ -528,7 +528,7 @@ if (!function_exists('request')) { */ function request(): Request { - return Snowflake::getDi()->get(Request::class); + return Kiri::getDi()->get(Request::class); } } @@ -557,7 +557,7 @@ if (!function_exists('storage')) { function storage(?string $fileName = '', ?string $path = ''): string { - $basePath = rtrim(Snowflake::getStoragePath(), '/'); + $basePath = rtrim(Kiri::getStoragePath(), '/'); if (!empty($path)) { $path = ltrim($path, '/'); if (!is_dir($basePath . '/' . $path)) { @@ -601,7 +601,7 @@ if (!function_exists('alias')) { */ function alias($class, $name) { - Snowflake::setAlias($class, $name); + Kiri::setAlias($class, $name); } } @@ -617,7 +617,7 @@ if (!function_exists('name')) { */ function name(int $pid, string $prefix = null) { - if (Snowflake::getPlatform()->isMac()) { + if (Kiri::getPlatform()->isMac()) { return; } @@ -700,7 +700,7 @@ if (!function_exists('di')) { */ function di(string $className): mixed { - return Snowflake::getDi()->get($className); + return Kiri::getDi()->get($className); } } @@ -806,7 +806,7 @@ if (!function_exists('router')) { */ function router(): Router { - return Snowflake::app()->getRouter(); + return Kiri::app()->getRouter(); } } @@ -823,7 +823,7 @@ if (!function_exists('isService')) { */ function isService(string $name): bool { - return Snowflake::app()->has($name); + return Kiri::app()->has($name); } } @@ -838,7 +838,7 @@ if (!function_exists('getService')) { */ function getService(string $name): mixed { - return Snowflake::app()->get($name); + return Kiri::app()->get($name); } } @@ -927,7 +927,7 @@ if (!function_exists('debug')) { */ function debug(mixed $message, string $method = 'app') { - Snowflake::app()->debug($message, $method); + Kiri::app()->debug($message, $method); } } @@ -941,7 +941,7 @@ if (!function_exists('error')) { */ function error(mixed $message, string $method = 'error') { - Snowflake::app()->error($message, $method); + Kiri::app()->error($message, $method); } } @@ -954,7 +954,7 @@ if (!function_exists('success')) { */ function success(mixed $message, string $method = 'app') { - Snowflake::app()->success($message, $method); + Kiri::app()->success($message, $method); } }