eee
This commit is contained in:
+6
-10
@@ -72,19 +72,15 @@ class Task
|
|||||||
*/
|
*/
|
||||||
public function onTask(Server $server, int $task_id, int $src_worker_id, mixed $data): void
|
public function onTask(Server $server, int $task_id, int $src_worker_id, mixed $data): void
|
||||||
{
|
{
|
||||||
$response = 'task data format failed.';
|
|
||||||
try {
|
try {
|
||||||
$data = json_decode($data, true);
|
[$handler, $params] = [$data[0], $data[1]];
|
||||||
if (!is_null($data)) {
|
|
||||||
[$handler, $params] = [$data[0], $data[1]];
|
|
||||||
|
|
||||||
$handler = Kiri::getDi()->make($handler, $params);
|
$handler = Kiri::getDi()->make($handler, $params);
|
||||||
if (!($handler instanceof OnTaskInterface)) {
|
if (!($handler instanceof OnTaskInterface)) {
|
||||||
throw new \Exception('Task process must implements ' . OnTaskInterface::class);
|
throw new \Exception('Task process must implements ' . OnTaskInterface::class);
|
||||||
}
|
|
||||||
|
|
||||||
$response = call_user_func([$handler, 'process'], $task_id, $src_worker_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = call_user_func([$handler, 'process'], $task_id, $src_worker_id);
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
$response = throwable($throwable);
|
$response = throwable($throwable);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user