modify plugin name
This commit is contained in:
@@ -27,8 +27,6 @@ use Psr\Log\LoggerInterface;
|
||||
abstract class BaseApplication extends Component
|
||||
{
|
||||
|
||||
use TraitApplication;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
abstract class Command extends Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri\Abstracts;
|
||||
|
||||
|
||||
use Kiri\Annotation\Annotation as SAnnotation;
|
||||
use Database\Connection;
|
||||
use Database\DatabasesProviders;
|
||||
use Kiri\Message\Handler\Router;
|
||||
use Kiri\Server\Server;
|
||||
use Kiri\Jwt\JWTAuth;
|
||||
|
||||
/**
|
||||
* Trait TraitApplication
|
||||
* @package Kiri\Abstracts
|
||||
* @property Router $router
|
||||
* @property Server $server
|
||||
* @property DatabasesProviders $db
|
||||
* @property JWTAuth $jwt
|
||||
* @property SAnnotation $annotation
|
||||
* @property Connection $databases
|
||||
*/
|
||||
trait TraitApplication
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace Kiri\Core;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Kiri\Abstracts\Component;
|
||||
|
||||
/**
|
||||
* Class Dtl
|
||||
* @package Kiri\Core
|
||||
*/
|
||||
class Dtl extends Component
|
||||
{
|
||||
|
||||
protected array $params;
|
||||
|
||||
|
||||
/**
|
||||
* Dtl constructor.
|
||||
* @param $params
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
parent::__construct([]);
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get($name): mixed
|
||||
{
|
||||
$array = $this->toArray();
|
||||
if (!isset($array[$name])) {
|
||||
return null;
|
||||
}
|
||||
return $array[$name];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri\Error;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Kiri\Core\Json;
|
||||
use Kiri\Exception\ComponentException;
|
||||
use Kiri;
|
||||
use Kiri\Server\Abstracts\BaseProcess;
|
||||
use Kiri\Server\Broadcast\OnBroadcastInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Process;
|
||||
|
||||
/**
|
||||
* Class LoggerProcess
|
||||
* @package Kiri\Error
|
||||
*/
|
||||
class LoggerProcess extends BaseProcess
|
||||
{
|
||||
|
||||
|
||||
public string $name = 'logger process';
|
||||
|
||||
|
||||
/**
|
||||
* @param Process $process
|
||||
* @throws ComponentException
|
||||
*/
|
||||
public function process(Process $process): void
|
||||
{
|
||||
// TODO: Implement onHandler() method.
|
||||
$this->message($process);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param OnBroadcastInterface $message
|
||||
* @return void
|
||||
*/
|
||||
public function onBroadcast(OnBroadcastInterface $message): void
|
||||
{
|
||||
$logger = Kiri::getDi()->get(LoggerInterface::class);
|
||||
$logger->debug($message->data . '::' . static::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Process $process
|
||||
* @throws ComponentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function message(Process $process)
|
||||
{
|
||||
if ($this->isStop()) {
|
||||
return;
|
||||
}
|
||||
$message = Json::decode($process->read());
|
||||
if (!empty($message)) {
|
||||
Kiri::writeFile($this->getDirName($message), $message[0], FILE_APPEND);
|
||||
|
||||
$this->checkLogFile($message[1]);
|
||||
}
|
||||
|
||||
Coroutine\System::sleep(1);
|
||||
|
||||
$this->message($process);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getDirName($message): string
|
||||
{
|
||||
return storage('server-' . date('Y-m-d') . '.log', $message[1]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dirName
|
||||
* @throws Exception
|
||||
*/
|
||||
private function checkLogFile($dirName)
|
||||
{
|
||||
$files = new \DirectoryIterator(storage(null, $dirName));
|
||||
if ($files->getSize() < 15) {
|
||||
return;
|
||||
}
|
||||
Coroutine\System::exec('find ' . storage(null, $dirName) . '/ -mtime +15 -name "*.log" -exec rm -rf {} \;');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri;
|
||||
|
||||
|
||||
interface IAspect
|
||||
{
|
||||
|
||||
|
||||
public function before(): void;
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $response
|
||||
*/
|
||||
public function after(mixed $response): void;
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $handler
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function invoke(mixed $handler, array $params = []): mixed;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user