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": {
"psr-4": {
"Kiri\\": "kiri-engine/",
"Kiri\\Gateway\\": "kiri-gateway/",
"Gii\\": "kiri-gii/",
"Annotation\\": "kiri-note/"
"Note\\": "kiri-note/"
},
"files": [
"error.php",
+7 -7
View File
@@ -3,8 +3,8 @@
defined('APP_PATH') or define('APP_PATH', realpath(__DIR__ . '/../../'));
use Annotation\Annotation;
use Annotation\Route\Route;
use Note\Note;
use Note\Route\Route;
use Http\Handler\Router;
use JetBrains\PhpStorm\Pure;
use Kiri\Abstracts\Config;
@@ -180,12 +180,12 @@ if (!function_exists('annotation')) {
/**
* @return Annotation
* @return Note
* @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 = [])
{
$annotation = Kiri::app()->getAnnotation();
$annotation = Kiri::app()->getNote();
$annotation->read($dir, $namespace, $exclude);
injectRuntime($dir, $exclude);
@@ -224,7 +224,7 @@ if (!function_exists('injectRuntime')) {
*/
function injectRuntime(string $path, array $exclude = [])
{
$fileLists = Kiri::getAnnotation()->runtime($path, $exclude);
$fileLists = Kiri::getNote()->runtime($path, $exclude);
$di = Kiri::getDi();
$router = [];
+4 -4
View File
@@ -10,7 +10,7 @@ declare(strict_types=1);
namespace Kiri\Abstracts;
use Annotation\Annotation as SAnnotation;
use Note\Note as SNote;
use Database\Connection;
use Exception;
use Http\Handler\Router;
@@ -392,10 +392,10 @@ abstract class BaseApplication extends Component
/**
* @return SAnnotation
* @return SNote
* @throws
*/
public function getAnnotation(): SAnnotation
public function getNote(): SNote
{
return $this->get('annotation');
}
@@ -450,7 +450,7 @@ abstract class BaseApplication extends Component
'error' => ['class' => ErrorHandler::class],
'config' => ['class' => Config::class],
'logger' => ['class' => Logger::class],
'annotation' => ['class' => SAnnotation::class],
'annotation' => ['class' => SNote::class],
'databases' => ['class' => Connection::class],
'jwt' => ['class' => Jwt::class],
'async' => ['class' => Async::class],
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Kiri\Abstracts;
use Annotation\Inject;
use Note\Inject;
use Exception;
use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException;
+2 -2
View File
@@ -4,7 +4,7 @@
namespace Kiri\Abstracts;
use Annotation\Annotation as SAnnotation;
use Note\Note as SNote;
use Database\Connection;
use Database\DatabasesProviders;
use Http\Handler\Client\Client;
@@ -25,7 +25,7 @@ use Kiri\Jwt\JWTAuth;
* @property Async $async
* @property Logger $logger
* @property JWTAuth $jwt
* @property SAnnotation $annotation
* @property SNote $annotation
* @property BaseGoto $goto
* @property Client $client
* @property Connection $databases
+1 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Cache;
use Annotation\Inject;
use Note\Inject;
use Exception;
use Server\Events\OnWorkerExit;
use Kiri\Abstracts\Component;
+1 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Di;
use Annotation\Inject;
use Note\Inject;
use Closure;
use Exception;
use Kiri\Abstracts\BaseObject;
+1 -1
View File
@@ -236,7 +236,7 @@ class NoteManager
* @param string $method
* @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);
if (empty($class) || !isset($class['property'])) {
+1 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Error;
use Annotation\Inject;
use Note\Inject;
use Exception;
use Kiri\Abstracts\Component;
use Kiri\Core\Json;
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Kiri\FileListen;
use Annotation\Inject;
use Note\Inject;
use Exception;
use Kiri\Abstracts\Config;
use Kiri\Error\Logger;
+4 -4
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Kiri;
use Annotation\Annotation;
use Note\Note;
use Database\Collection;
use Database\ModelInterface;
use Exception;
@@ -156,12 +156,12 @@ class Kiri
/**
* @return Annotation
* @return Note
* @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
{
// TODO: Implement onHandler() method.
$annotation = Kiri::app()->getAnnotation();
$annotation = Kiri::app()->getNote();
$runtime = storage(static::CACHE_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 {
$import = "use Kiri;
use Exception;
use Annotation\Target;
use Annotation\Route\Middleware;
use Annotation\Route\Route;
use Note\Target;
use Note\Route\Middleware;
use Note\Route\Route;
use Kiri\Core\Str;
use Kiri\Core\Json;
use Http\Context\Request;
+4 -4
View File
@@ -51,8 +51,8 @@ interface ' . ucfirst($name) . 'RpcInterface
namespace Rpc\Producers;
use Annotation\Target;
use Annotation\Mapping;
use Note\Target;
use Note\Mapping;
use Rpc\\' . ucfirst($name) . 'RpcInterface;
use Exception;
use Kiri\Rpc\JsonRpcConsumers;
@@ -86,8 +86,8 @@ class ' . ucfirst($name) . 'RpcService extends JsonRpcConsumers implements ' . u
namespace Rpc\Consumers;
use Annotation\Target;
use Kiri\Rpc\Annotation\JsonRpc;
use Note\Target;
use Kiri\Rpc\Note\JsonRpc;
use Http\Handler\Controller;
use Rpc\\' . ucfirst($name) . 'RpcInterface;
+7 -7
View File
@@ -69,11 +69,11 @@ namespace ' . $namespace . ';
$html .= $imports . PHP_EOL;
}
if (!str_contains($imports, 'Database\Annotation\Set')) {
$html .= 'use Database\Annotation\Set;' . PHP_EOL;
if (!str_contains($imports, 'Database\Note\Set')) {
$html .= 'use Database\Note\Set;' . PHP_EOL;
}
if (!str_contains($imports, 'Database\Annotation\Get')) {
$html .= 'use Database\Annotation\Get;' . PHP_EOL;
if (!str_contains($imports, 'Database\Note\Get')) {
$html .= 'use Database\Note\Get;' . PHP_EOL;
}
} catch (\Throwable $e) {
logger()->addError($e, 'throwable');
@@ -87,11 +87,11 @@ namespace ' . $namespace . ';
use Exception;
use Annotation\Target;
use Note\Target;
use Kiri\Core\Json;
use Database\Connection;
use Database\Annotation\Get;
use Database\Annotation\Set;
use Database\Note\Get;
use Database\Note\Set;
use Database\Relation;
use Database\Model;
' . PHP_EOL;
+3 -3
View File
@@ -36,9 +36,9 @@ class GiiRpcClient extends GiiBase
namespace App\Client\Rpc;
use Annotation\Rpc\Consumer;
use Annotation\Rpc\RpcClient;
use Annotation\Target;
use Note\Rpc\Consumer;
use Note\Rpc\RpcClient;
use Note\Target;
use Exception;
use Rpc\Client;
use Kiri\Core\Json;
+2 -2
View File
@@ -33,8 +33,8 @@ class GiiRpcService extends GiiBase
namespace App\Rpc;
use Annotation\Route\RpcProducer;
use Annotation\Target;
use Note\Route\RpcProducer;
use Note\Target;
use Exception;
use Http\Controller;
use Kiri\Core\Json;
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
namespace Annotation;
namespace Note;
use Exception;
@@ -10,7 +10,7 @@ defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implem
/**
* Class Aspect
* @package Annotation
* @package Note
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends Attribute
{
+3 -3
View File
@@ -1,14 +1,14 @@
<?php
namespace Annotation;
namespace Note;
/**
* 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
namespace Annotation;
namespace Note;
use Exception;
@@ -11,7 +11,7 @@ use Kiri\Kiri;
/**
* Class Event
* @package Annotation
* @package Note
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Event extends Attribute
{
@@ -1,11 +1,11 @@
<?php
namespace Annotation;
namespace Note;
interface IAnnotation
interface INote
{
/**
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
namespace Annotation;
namespace Note;
use Exception;
@@ -12,7 +12,7 @@ use ReflectionProperty;
/**
* Class Inject
* @package Annotation
* @package Note
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)] class Inject extends Attribute
{
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
namespace Annotation;
namespace Note;
use DirectoryIterator;
@@ -15,7 +15,7 @@ use Throwable;
/**
* Class Loader
* @package Annotation
* @package Note
*/
class Loader extends BaseObject
{
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace Annotation;
namespace Note;
use Kiri\Kiri;
@@ -1,7 +1,7 @@
<?php
namespace Annotation;
namespace Note;
use DirectoryIterator;
@@ -10,10 +10,10 @@ use ReflectionException;
use Kiri\Abstracts\Component;
/**
* Class Annotation
* @package Annotation
* Class Note
* @package Note
*/
class Annotation extends Component
class Note extends Component
{
+3 -3
View File
@@ -1,14 +1,14 @@
<?php
namespace Annotation\Route;
namespace Note\Route;
use Annotation\Attribute;
use Note\Attribute;
/**
* Class Document
* @package Annotation\Route
* @package Note\Route
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Document extends Attribute
{
+3 -3
View File
@@ -1,16 +1,16 @@
<?php
namespace Annotation\Route;
namespace Note\Route;
use Annotation\Attribute;
use Note\Attribute;
use Http\Handler\Abstracts\MiddlewareManager;
use Psr\Http\Server\MiddlewareInterface;
/**
* Class Middleware
* @package Annotation\Route
* @package Note\Route
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Middleware extends Attribute
{
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
namespace Annotation\Route;
namespace Note\Route;
use Annotation\Attribute;
use Note\Attribute;
use Http\Handler\Router;
use Kiri\Kiri;
+3 -3
View File
@@ -1,14 +1,14 @@
<?php
namespace Annotation\Route;
namespace Note\Route;
use Annotation\Attribute;
use Note\Attribute;
/**
* Class Socket
* @package Annotation
* @package Note
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Socket extends Attribute
{
+2 -2
View File
@@ -1,12 +1,12 @@
<?php
namespace Annotation;
namespace Note;
/**
* Class Target
* @package Annotation
* @package Note
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Target extends Attribute
{
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
namespace Annotation;
namespace Note;
use Exception;
@@ -11,7 +11,7 @@ use Server\Tasker\AsyncTaskExecute;
/**
* Class Task
* @package Annotation
* @package Note
* Task任务
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Task extends Attribute
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Kiri\Server;
use Annotation\Inject;
use Note\Inject;
use Exception;
use Kiri\Abstracts\Config;
use Kiri\Error\Logger;
+4 -3
View File
@@ -2,13 +2,14 @@
namespace Kiri\Server;
use Annotation\Inject;
use Note\Inject;
use Exception;
use Kiri\Abstracts\Config;
use Kiri\Error\Logger;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Kiri\Server\Abstracts\BaseProcess;
use ReflectionException;
use Swoole\Http\Server as HServer;
use Swoole\Process;
use Swoole\Server;
@@ -54,7 +55,7 @@ class SoloAsyncServer implements SwooleServerInterface
/**
* @throws ConfigException|\ReflectionException
* @throws ConfigException|ReflectionException
*/
private function startProcess()
{
@@ -100,7 +101,7 @@ class SoloAsyncServer implements SwooleServerInterface
/**
* @param Server\Port|Server|HServer|WServer $server
* @throws \ReflectionException
* @throws ReflectionException
*/
private function eventListener(mixed $server, array $config): Server\Port|HServer|Server|WServer
{