This commit is contained in:
2025-07-11 15:04:25 +08:00
parent 7b8a43f94f
commit 397cfc039b
+6 -10
View File
@@ -72,19 +72,15 @@ class Task
*/
public function onTask(Server $server, int $task_id, int $src_worker_id, mixed $data): void
{
$response = 'task data format failed.';
try {
$data = json_decode($data, true);
if (!is_null($data)) {
[$handler, $params] = [$data[0], $data[1]];
[$handler, $params] = [$data[0], $data[1]];
$handler = Kiri::getDi()->make($handler, $params);
if (!($handler instanceof OnTaskInterface)) {
throw new \Exception('Task process must implements ' . OnTaskInterface::class);
}
$response = call_user_func([$handler, 'process'], $task_id, $src_worker_id);
$handler = Kiri::getDi()->make($handler, $params);
if (!($handler instanceof OnTaskInterface)) {
throw new \Exception('Task process must implements ' . OnTaskInterface::class);
}
$response = call_user_func([$handler, 'process'], $task_id, $src_worker_id);
} catch (\Throwable $throwable) {
$response = throwable($throwable);
} finally {