Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e54326aba | |||
| 59632ac4a3 | |||
| da5a6a6b83 | |||
| d758d21f08 | |||
| c59212da78 | |||
| 9ce0cb96bf | |||
| c7b5d5fb59 |
+4
-5
@@ -9,7 +9,7 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.3",
|
"php": ">=8.4",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-fileinfo": "*",
|
"ext-fileinfo": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
@@ -23,19 +23,18 @@
|
|||||||
"ext-openssl": "*",
|
"ext-openssl": "*",
|
||||||
"ext-swoole": "*",
|
"ext-swoole": "*",
|
||||||
"ext-msgpack": "*",
|
"ext-msgpack": "*",
|
||||||
"symfony/console": "~v5.3.10",
|
"symfony/console": "^v7.3.1",
|
||||||
"psr/log": "1.*",
|
"psr/log": "1.*",
|
||||||
"composer-runtime-api": "^2.0",
|
"composer-runtime-api": "^2.0",
|
||||||
"psr/http-server-middleware": "1.0.1",
|
"psr/http-server-middleware": "1.0.1",
|
||||||
"ext-pcntl": "*",
|
"ext-pcntl": "*",
|
||||||
"ext-sockets": "*",
|
"ext-sockets": "*",
|
||||||
"nikic/php-parser": "^4.15",
|
"nikic/php-parser": "^v5.5.0",
|
||||||
"ext-inotify": "*",
|
"ext-inotify": "*",
|
||||||
"game-worker/kiri-pool": "~v1.0",
|
"game-worker/kiri-pool": "~v1.0",
|
||||||
"monolog/monolog": "^2.9",
|
"monolog/monolog": "^2.9",
|
||||||
"psr/container": "^2.0",
|
"psr/container": "^2.0",
|
||||||
"ext-libsodium": "*",
|
"swiftmailer/swiftmailer": "^v6.3.0"
|
||||||
"swiftmailer/swiftmailer": "^6.3"
|
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"symfony/polyfill-apcu": "*",
|
"symfony/polyfill-apcu": "*",
|
||||||
|
|||||||
+69
-4
@@ -13,6 +13,7 @@ use Kiri\Events\EventDispatch;
|
|||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
use Kiri\Router\Request;
|
use Kiri\Router\Request;
|
||||||
use Kiri\Router\Response;
|
use Kiri\Router\Response;
|
||||||
|
use Kiri\Server\Task\TaskExecute;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
@@ -60,6 +61,67 @@ if (!function_exists('application')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('task')) {
|
||||||
|
/**
|
||||||
|
* @param string $handler
|
||||||
|
* @param mixed $data
|
||||||
|
* @param int $dstWorkerId
|
||||||
|
* @param callable|null $finishFinishCallback
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function task(string $handler, mixed $data, int $dstWorkerId = -1, ?callable $finishFinishCallback = null): void
|
||||||
|
{
|
||||||
|
$execute = Kiri::getDi()->get(TaskExecute::class);
|
||||||
|
$execute->task($handler, $data, $dstWorkerId, $finishFinishCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('taskWait')) {
|
||||||
|
/**
|
||||||
|
* @param string $handler
|
||||||
|
* @param mixed $data
|
||||||
|
* @param float $timeout
|
||||||
|
* @param int $dstWorkerId
|
||||||
|
* @return mixed
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function taskWait(string $handler, mixed $data, float $timeout = 0.5, int $dstWorkerId = -1): mixed
|
||||||
|
{
|
||||||
|
$execute = Kiri::getDi()->get(TaskExecute::class);
|
||||||
|
return $execute->taskWait($handler, $data, $timeout, $dstWorkerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('taskCo')) {
|
||||||
|
/**
|
||||||
|
* @param array $tasks
|
||||||
|
* @param float $timeout
|
||||||
|
* @return false|array
|
||||||
|
*/
|
||||||
|
function taskCo(array $tasks, float $timeout = 0.5): false|array
|
||||||
|
{
|
||||||
|
$execute = Kiri::getDi()->get(TaskExecute::class);
|
||||||
|
return $execute->taskCo($tasks, $timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('taskWaitMulti')) {
|
||||||
|
/**
|
||||||
|
* @param array $tasks
|
||||||
|
* @param float $timeout
|
||||||
|
* @return false|array
|
||||||
|
*/
|
||||||
|
function taskWaitMulti(array $tasks, float $timeout = 0.5): false|array
|
||||||
|
{
|
||||||
|
$execute = Kiri::getDi()->get(TaskExecute::class);
|
||||||
|
return $execute->taskWaitMulti($tasks, $timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('make')) {
|
if (!function_exists('make')) {
|
||||||
|
|
||||||
|
|
||||||
@@ -85,7 +147,8 @@ if (!function_exists('isJson')) {
|
|||||||
|
|
||||||
function isJson(?string $string): bool
|
function isJson(?string $string): bool
|
||||||
{
|
{
|
||||||
if (is_null($string)) return false;
|
if (is_null($string))
|
||||||
|
return false;
|
||||||
return (str_starts_with($string, '{') && str_ends_with($string, '}'))
|
return (str_starts_with($string, '{') && str_ends_with($string, '}'))
|
||||||
|| (str_ends_with($string, '[') && str_starts_with($string, ']'));
|
|| (str_ends_with($string, '[') && str_starts_with($string, ']'));
|
||||||
}
|
}
|
||||||
@@ -145,7 +208,8 @@ if (!function_exists('checkPortIsAlready')) {
|
|||||||
{
|
{
|
||||||
if (!Kiri::getPlatform()->isLinux()) {
|
if (!Kiri::getPlatform()->isLinux()) {
|
||||||
exec("lsof -i :" . $port . " | grep -i 'LISTEN' | awk '{print $2}'", $output);
|
exec("lsof -i :" . $port . " | grep -i 'LISTEN' | awk '{print $2}'", $output);
|
||||||
if (empty($output)) return FALSE;
|
if (empty($output))
|
||||||
|
return FALSE;
|
||||||
$output = explode(PHP_EOL, $output[0]);
|
$output = explode(PHP_EOL, $output[0]);
|
||||||
return $output[0];
|
return $output[0];
|
||||||
}
|
}
|
||||||
@@ -699,7 +763,7 @@ if (!function_exists('process_name_set')) {
|
|||||||
* @param string|null $prefix
|
* @param string|null $prefix
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
function process_name_set(int $pid, string $prefix = NULL): void
|
function process_name_set(int $pid, ?string $prefix = NULL): void
|
||||||
{
|
{
|
||||||
if (Kiri::getPlatform()->isMac()) {
|
if (Kiri::getPlatform()->isMac()) {
|
||||||
return;
|
return;
|
||||||
@@ -845,7 +909,8 @@ if (!function_exists('jTraceEx')) {
|
|||||||
{
|
{
|
||||||
$starter = $seen ? 'Caused by: ' : '';
|
$starter = $seen ? 'Caused by: ' : '';
|
||||||
$result = [];
|
$result = [];
|
||||||
if (!$seen) $seen = [];
|
if (!$seen)
|
||||||
|
$seen = [];
|
||||||
$trace = $e->getTrace();
|
$trace = $e->getTrace();
|
||||||
$prev = $e->getPrevious();
|
$prev = $e->getPrevious();
|
||||||
$result[] = sprintf('%s%s: %s', $starter, $e::class, $e->getMessage());
|
$result[] = sprintf('%s%s: %s', $starter, $e::class, $e->getMessage());
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class Str
|
|||||||
* @return array
|
* @return array
|
||||||
* 剩余天,带分秒
|
* 剩余天,带分秒
|
||||||
*/
|
*/
|
||||||
public static function timeout($endTime, int $startTime = NULL): array
|
public static function timeout($endTime, ?int $startTime = NULL): array
|
||||||
{
|
{
|
||||||
$endTime = $endTime - (!empty($startTime) ? $startTime : time());
|
$endTime = $endTime - (!empty($startTime) ? $startTime : time());
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,12 @@ namespace Kiri\Error;
|
|||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use Kiri\Di\Inject\Container;
|
|
||||||
use ReflectionException;
|
|
||||||
use Kiri\Events\OnSystemError;
|
use Kiri\Events\OnSystemError;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ErrorHandler
|
* Class ErrorHandler
|
||||||
* hahahah
|
|
||||||
* @package Kiri\Base
|
* @package Kiri\Base
|
||||||
* @property-read $asError
|
* @property-read $asError
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use Monolog\Formatter\LineFormatter;
|
|||||||
use Monolog\Handler\RotatingFileHandler;
|
use Monolog\Handler\RotatingFileHandler;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use ReflectionException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,12 +9,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Kiri\Redis;
|
namespace Kiri\Redis;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Kiri;
|
use Kiri;
|
||||||
use Kiri\Exception\RedisConnectException;
|
use Kiri\Exception\RedisConnectException;
|
||||||
use Kiri\Pool\Pool;
|
use Kiri\Pool\Pool;
|
||||||
use RedisException;
|
|
||||||
use wchat\common\Result;
|
|
||||||
use function config;
|
use function config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user