This commit is contained in:
2021-11-30 15:10:01 +08:00
parent e5b57cbcdb
commit b826e1f594
36 changed files with 155 additions and 81 deletions
+2 -1
View File
@@ -36,8 +36,9 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Kiri\\": "kiri-engine/", "Kiri\\": "kiri-engine/",
"Kiri\\Gateway\\": "kiri-gateway/",
"Gii\\": "kiri-gii/", "Gii\\": "kiri-gii/",
"Annotation\\": "kiri-note/" "Note\\": "kiri-note/"
}, },
"files": [ "files": [
"error.php", "error.php",
+7 -7
View File
@@ -3,8 +3,8 @@
defined('APP_PATH') or define('APP_PATH', realpath(__DIR__ . '/../../')); defined('APP_PATH') or define('APP_PATH', realpath(__DIR__ . '/../../'));
use Annotation\Annotation; use Note\Note;
use Annotation\Route\Route; use Note\Route\Route;
use Http\Handler\Router; use Http\Handler\Router;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
@@ -180,12 +180,12 @@ if (!function_exists('annotation')) {
/** /**
* @return Annotation * @return Note
* @throws Exception * @throws Exception
*/ */
function annotation(): Annotation function annotation(): Note
{ {
return Kiri::getAnnotation(); return Kiri::getNote();
} }
@@ -204,7 +204,7 @@ if (!function_exists('scan_directory')) {
*/ */
function scan_directory($dir, $namespace, array $exclude = []) function scan_directory($dir, $namespace, array $exclude = [])
{ {
$annotation = Kiri::app()->getAnnotation(); $annotation = Kiri::app()->getNote();
$annotation->read($dir, $namespace, $exclude); $annotation->read($dir, $namespace, $exclude);
injectRuntime($dir, $exclude); injectRuntime($dir, $exclude);
@@ -224,7 +224,7 @@ if (!function_exists('injectRuntime')) {
*/ */
function injectRuntime(string $path, array $exclude = []) function injectRuntime(string $path, array $exclude = [])
{ {
$fileLists = Kiri::getAnnotation()->runtime($path, $exclude); $fileLists = Kiri::getNote()->runtime($path, $exclude);
$di = Kiri::getDi(); $di = Kiri::getDi();
$router = []; $router = [];
+4 -4
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Kiri\Abstracts; namespace Kiri\Abstracts;
use Annotation\Annotation as SAnnotation; use Note\Note as SNote;
use Database\Connection; use Database\Connection;
use Exception; use Exception;
use Http\Handler\Router; use Http\Handler\Router;
@@ -392,10 +392,10 @@ abstract class BaseApplication extends Component
/** /**
* @return SAnnotation * @return SNote
* @throws * @throws
*/ */
public function getAnnotation(): SAnnotation public function getNote(): SNote
{ {
return $this->get('annotation'); return $this->get('annotation');
} }
@@ -450,7 +450,7 @@ abstract class BaseApplication extends Component
'error' => ['class' => ErrorHandler::class], 'error' => ['class' => ErrorHandler::class],
'config' => ['class' => Config::class], 'config' => ['class' => Config::class],
'logger' => ['class' => Logger::class], 'logger' => ['class' => Logger::class],
'annotation' => ['class' => SAnnotation::class], 'annotation' => ['class' => SNote::class],
'databases' => ['class' => Connection::class], 'databases' => ['class' => Connection::class],
'jwt' => ['class' => Jwt::class], 'jwt' => ['class' => Jwt::class],
'async' => ['class' => Async::class], 'async' => ['class' => Async::class],
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Kiri\Abstracts; namespace Kiri\Abstracts;
use Annotation\Inject; use Note\Inject;
use Exception; use Exception;
use Kiri\Events\EventProvider; use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
+2 -2
View File
@@ -4,7 +4,7 @@
namespace Kiri\Abstracts; namespace Kiri\Abstracts;
use Annotation\Annotation as SAnnotation; use Note\Note as SNote;
use Database\Connection; use Database\Connection;
use Database\DatabasesProviders; use Database\DatabasesProviders;
use Http\Handler\Client\Client; use Http\Handler\Client\Client;
@@ -25,7 +25,7 @@ use Kiri\Jwt\JWTAuth;
* @property Async $async * @property Async $async
* @property Logger $logger * @property Logger $logger
* @property JWTAuth $jwt * @property JWTAuth $jwt
* @property SAnnotation $annotation * @property SNote $annotation
* @property BaseGoto $goto * @property BaseGoto $goto
* @property Client $client * @property Client $client
* @property Connection $databases * @property Connection $databases
+1 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Cache; namespace Kiri\Cache;
use Annotation\Inject; use Note\Inject;
use Exception; use Exception;
use Server\Events\OnWorkerExit; use Server\Events\OnWorkerExit;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
+1 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Di; namespace Kiri\Di;
use Annotation\Inject; use Note\Inject;
use Closure; use Closure;
use Exception; use Exception;
use Kiri\Abstracts\BaseObject; use Kiri\Abstracts\BaseObject;
+1 -1
View File
@@ -236,7 +236,7 @@ class NoteManager
* @param string $method * @param string $method
* @return mixed * @return mixed
*/ */
public static function getPropertyByAnnotation(string $attribute, string $class, string $method): mixed public static function getPropertyByNote(string $attribute, string $class, string $method): mixed
{ {
$class = self::getAttributeTrees($attribute, $class); $class = self::getAttributeTrees($attribute, $class);
if (empty($class) || !isset($class['property'])) { if (empty($class) || !isset($class['property'])) {
+1 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Error; namespace Kiri\Error;
use Annotation\Inject; use Note\Inject;
use Exception; use Exception;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
use Kiri\Core\Json; use Kiri\Core\Json;
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Kiri\FileListen; namespace Kiri\FileListen;
use Annotation\Inject; use Note\Inject;
use Exception; use Exception;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Error\Logger; use Kiri\Error\Logger;
+4 -4
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Kiri; namespace Kiri;
use Annotation\Annotation; use Note\Note;
use Database\Collection; use Database\Collection;
use Database\ModelInterface; use Database\ModelInterface;
use Exception; use Exception;
@@ -156,12 +156,12 @@ class Kiri
/** /**
* @return Annotation * @return Note
* @throws Exception * @throws Exception
*/ */
public static function getAnnotation(): Annotation public static function getNote(): Note
{ {
return static::app()->getAnnotation(); return static::app()->getNote();
} }
+1 -1
View File
@@ -43,7 +43,7 @@ class Runtime extends Command
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
// TODO: Implement onHandler() method. // TODO: Implement onHandler() method.
$annotation = Kiri::app()->getAnnotation(); $annotation = Kiri::app()->getNote();
$runtime = storage(static::CACHE_NAME); $runtime = storage(static::CACHE_NAME);
$config = storage(static::CONFIG_NAME); $config = storage(static::CONFIG_NAME);
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace Kiri\Gateway;
class Collector
{
public function get()
{
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Kiri\Gateway;
use Swoole\Http\Request;
use Swoole\Http\Response;
class GatewayServer
{
/**
* @param Request $request
* @param Response $response
*/
public function onRequest(Request $request, Response $response)
{
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace Kiri\Gateway;
class HashMap
{
const HTTP = 1;
const TCP = 2;
const UDP = 2;
public string $domain;
public string $path;
public string $scheme;
public string $method;
public string $proxy_host;
public string $proxy_port;
public int $type = self::HTTP;
}
+3 -3
View File
@@ -68,9 +68,9 @@ namespace {$namespace};
} else { } else {
$import = "use Kiri; $import = "use Kiri;
use Exception; use Exception;
use Annotation\Target; use Note\Target;
use Annotation\Route\Middleware; use Note\Route\Middleware;
use Annotation\Route\Route; use Note\Route\Route;
use Kiri\Core\Str; use Kiri\Core\Str;
use Kiri\Core\Json; use Kiri\Core\Json;
use Http\Context\Request; use Http\Context\Request;
+4 -4
View File
@@ -51,8 +51,8 @@ interface ' . ucfirst($name) . 'RpcInterface
namespace Rpc\Producers; namespace Rpc\Producers;
use Annotation\Target; use Note\Target;
use Annotation\Mapping; use Note\Mapping;
use Rpc\\' . ucfirst($name) . 'RpcInterface; use Rpc\\' . ucfirst($name) . 'RpcInterface;
use Exception; use Exception;
use Kiri\Rpc\JsonRpcConsumers; use Kiri\Rpc\JsonRpcConsumers;
@@ -86,8 +86,8 @@ class ' . ucfirst($name) . 'RpcService extends JsonRpcConsumers implements ' . u
namespace Rpc\Consumers; namespace Rpc\Consumers;
use Annotation\Target; use Note\Target;
use Kiri\Rpc\Annotation\JsonRpc; use Kiri\Rpc\Note\JsonRpc;
use Http\Handler\Controller; use Http\Handler\Controller;
use Rpc\\' . ucfirst($name) . 'RpcInterface; use Rpc\\' . ucfirst($name) . 'RpcInterface;
+7 -7
View File
@@ -69,11 +69,11 @@ namespace ' . $namespace . ';
$html .= $imports . PHP_EOL; $html .= $imports . PHP_EOL;
} }
if (!str_contains($imports, 'Database\Annotation\Set')) { if (!str_contains($imports, 'Database\Note\Set')) {
$html .= 'use Database\Annotation\Set;' . PHP_EOL; $html .= 'use Database\Note\Set;' . PHP_EOL;
} }
if (!str_contains($imports, 'Database\Annotation\Get')) { if (!str_contains($imports, 'Database\Note\Get')) {
$html .= 'use Database\Annotation\Get;' . PHP_EOL; $html .= 'use Database\Note\Get;' . PHP_EOL;
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
logger()->addError($e, 'throwable'); logger()->addError($e, 'throwable');
@@ -87,11 +87,11 @@ namespace ' . $namespace . ';
use Exception; use Exception;
use Annotation\Target; use Note\Target;
use Kiri\Core\Json; use Kiri\Core\Json;
use Database\Connection; use Database\Connection;
use Database\Annotation\Get; use Database\Note\Get;
use Database\Annotation\Set; use Database\Note\Set;
use Database\Relation; use Database\Relation;
use Database\Model; use Database\Model;
' . PHP_EOL; ' . PHP_EOL;
+3 -3
View File
@@ -36,9 +36,9 @@ class GiiRpcClient extends GiiBase
namespace App\Client\Rpc; namespace App\Client\Rpc;
use Annotation\Rpc\Consumer; use Note\Rpc\Consumer;
use Annotation\Rpc\RpcClient; use Note\Rpc\RpcClient;
use Annotation\Target; use Note\Target;
use Exception; use Exception;
use Rpc\Client; use Rpc\Client;
use Kiri\Core\Json; use Kiri\Core\Json;
+2 -2
View File
@@ -33,8 +33,8 @@ class GiiRpcService extends GiiBase
namespace App\Rpc; namespace App\Rpc;
use Annotation\Route\RpcProducer; use Note\Route\RpcProducer;
use Annotation\Target; use Note\Target;
use Exception; use Exception;
use Http\Controller; use Http\Controller;
use Kiri\Core\Json; use Kiri\Core\Json;
+2 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Annotation; namespace Note;
use Exception; use Exception;
@@ -10,7 +10,7 @@ defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implem
/** /**
* Class Aspect * Class Aspect
* @package Annotation * @package Note
*/ */
#[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends Attribute #[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends Attribute
{ {
+3 -3
View File
@@ -1,14 +1,14 @@
<?php <?php
namespace Annotation; namespace Note;
/** /**
* Class Attribute * Class Attribute
* @package Annotation * @package Note
*/ */
abstract class Attribute implements IAnnotation abstract class Attribute implements INote
{ {
+2 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Annotation; namespace Note;
use Exception; use Exception;
@@ -11,7 +11,7 @@ use Kiri\Kiri;
/** /**
* Class Event * Class Event
* @package Annotation * @package Note
*/ */
#[\Attribute(\Attribute::TARGET_METHOD)] class Event extends Attribute #[\Attribute(\Attribute::TARGET_METHOD)] class Event extends Attribute
{ {
@@ -1,11 +1,11 @@
<?php <?php
namespace Annotation; namespace Note;
interface IAnnotation interface INote
{ {
/** /**
+2 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Annotation; namespace Note;
use Exception; use Exception;
@@ -12,7 +12,7 @@ use ReflectionProperty;
/** /**
* Class Inject * Class Inject
* @package Annotation * @package Note
*/ */
#[\Attribute(\Attribute::TARGET_PROPERTY)] class Inject extends Attribute #[\Attribute(\Attribute::TARGET_PROPERTY)] class Inject extends Attribute
{ {
+2 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Annotation; namespace Note;
use DirectoryIterator; use DirectoryIterator;
@@ -15,7 +15,7 @@ use Throwable;
/** /**
* Class Loader * Class Loader
* @package Annotation * @package Note
*/ */
class Loader extends BaseObject class Loader extends BaseObject
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
namespace Annotation; namespace Note;
use Kiri\Kiri; use Kiri\Kiri;
@@ -1,7 +1,7 @@
<?php <?php
namespace Annotation; namespace Note;
use DirectoryIterator; use DirectoryIterator;
@@ -10,10 +10,10 @@ use ReflectionException;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
/** /**
* Class Annotation * Class Note
* @package Annotation * @package Note
*/ */
class Annotation extends Component class Note extends Component
{ {
+3 -3
View File
@@ -1,14 +1,14 @@
<?php <?php
namespace Annotation\Route; namespace Note\Route;
use Annotation\Attribute; use Note\Attribute;
/** /**
* Class Document * Class Document
* @package Annotation\Route * @package Note\Route
*/ */
#[\Attribute(\Attribute::TARGET_METHOD)] class Document extends Attribute #[\Attribute(\Attribute::TARGET_METHOD)] class Document extends Attribute
{ {
+3 -3
View File
@@ -1,16 +1,16 @@
<?php <?php
namespace Annotation\Route; namespace Note\Route;
use Annotation\Attribute; use Note\Attribute;
use Http\Handler\Abstracts\MiddlewareManager; use Http\Handler\Abstracts\MiddlewareManager;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;
/** /**
* Class Middleware * Class Middleware
* @package Annotation\Route * @package Note\Route
*/ */
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Middleware extends Attribute #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Middleware extends Attribute
{ {
+2 -2
View File
@@ -1,10 +1,10 @@
<?php <?php
namespace Annotation\Route; namespace Note\Route;
use Annotation\Attribute; use Note\Attribute;
use Http\Handler\Router; use Http\Handler\Router;
use Kiri\Kiri; use Kiri\Kiri;
+3 -3
View File
@@ -1,14 +1,14 @@
<?php <?php
namespace Annotation\Route; namespace Note\Route;
use Annotation\Attribute; use Note\Attribute;
/** /**
* Class Socket * Class Socket
* @package Annotation * @package Note
*/ */
#[\Attribute(\Attribute::TARGET_METHOD)] class Socket extends Attribute #[\Attribute(\Attribute::TARGET_METHOD)] class Socket extends Attribute
{ {
+2 -2
View File
@@ -1,12 +1,12 @@
<?php <?php
namespace Annotation; namespace Note;
/** /**
* Class Target * Class Target
* @package Annotation * @package Note
*/ */
#[\Attribute(\Attribute::TARGET_CLASS)] class Target extends Attribute #[\Attribute(\Attribute::TARGET_CLASS)] class Target extends Attribute
{ {
+2 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Annotation; namespace Note;
use Exception; use Exception;
@@ -11,7 +11,7 @@ use Server\Tasker\AsyncTaskExecute;
/** /**
* Class Task * Class Task
* @package Annotation * @package Note
* Task任务 * Task任务
*/ */
#[\Attribute(\Attribute::TARGET_CLASS)] class Task extends Attribute #[\Attribute(\Attribute::TARGET_CLASS)] class Task extends Attribute
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Kiri\Server; namespace Kiri\Server;
use Annotation\Inject; use Note\Inject;
use Exception; use Exception;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Error\Logger; use Kiri\Error\Logger;
+4 -3
View File
@@ -2,13 +2,14 @@
namespace Kiri\Server; namespace Kiri\Server;
use Annotation\Inject; use Note\Inject;
use Exception; use Exception;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Error\Logger; use Kiri\Error\Logger;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
use Kiri\Kiri; use Kiri\Kiri;
use Kiri\Server\Abstracts\BaseProcess; use Kiri\Server\Abstracts\BaseProcess;
use ReflectionException;
use Swoole\Http\Server as HServer; use Swoole\Http\Server as HServer;
use Swoole\Process; use Swoole\Process;
use Swoole\Server; use Swoole\Server;
@@ -54,7 +55,7 @@ class SoloAsyncServer implements SwooleServerInterface
/** /**
* @throws ConfigException|\ReflectionException * @throws ConfigException|ReflectionException
*/ */
private function startProcess() private function startProcess()
{ {
@@ -100,7 +101,7 @@ class SoloAsyncServer implements SwooleServerInterface
/** /**
* @param Server\Port|Server|HServer|WServer $server * @param Server\Port|Server|HServer|WServer $server
* @throws \ReflectionException * @throws ReflectionException
*/ */
private function eventListener(mixed $server, array $config): Server\Port|HServer|Server|WServer private function eventListener(mixed $server, array $config): Server\Port|HServer|Server|WServer
{ {