eee
This commit is contained in:
+68
-3
@@ -13,6 +13,7 @@ use Kiri\Events\EventDispatch;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Router\Request;
|
||||
use Kiri\Router\Response;
|
||||
use Kiri\Server\Task\TaskExecute;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
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')) {
|
||||
|
||||
|
||||
@@ -85,7 +147,8 @@ if (!function_exists('isJson')) {
|
||||
|
||||
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, '}'))
|
||||
|| (str_ends_with($string, '[') && str_starts_with($string, ']'));
|
||||
}
|
||||
@@ -145,7 +208,8 @@ if (!function_exists('checkPortIsAlready')) {
|
||||
{
|
||||
if (!Kiri::getPlatform()->isLinux()) {
|
||||
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]);
|
||||
return $output[0];
|
||||
}
|
||||
@@ -845,7 +909,8 @@ if (!function_exists('jTraceEx')) {
|
||||
{
|
||||
$starter = $seen ? 'Caused by: ' : '';
|
||||
$result = [];
|
||||
if (!$seen) $seen = [];
|
||||
if (!$seen)
|
||||
$seen = [];
|
||||
$trace = $e->getTrace();
|
||||
$prev = $e->getPrevious();
|
||||
$result[] = sprintf('%s%s: %s', $starter, $e::class, $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user