This commit is contained in:
as2252258@163.com
2021-02-28 14:46:17 +08:00
parent ffc02cc33a
commit 5a0c35453d
2 changed files with 209 additions and 206 deletions
+6 -3
View File
@@ -6,6 +6,7 @@ namespace HttpServer\Events;
use Exception;
use HttpServer\Abstracts\Callback;
use Snowflake\Event;
use Snowflake\Snowflake;
use Swoole\Server;
@@ -23,9 +24,11 @@ class OnFinish extends Callback
*/
public function onHandler(Server $server, $task_id, $data)
{
$data = json_decode($data, true);
$data['work_id'] = $task_id;
$this->write(var_export($data, true), 'Task');
try {
fire(Event::TASK_FINISH, [$task_id, $data]);
} catch (\Throwable $exception) {
$this->addError($exception, 'task');
}
}
}
+1 -1
View File
@@ -26,6 +26,7 @@ class Event extends BaseObject
const EVENT_EXIT = 'WORKER:EXIT';
const PIPE_MESSAGE = 'SERVER:PIPE:MESSAGE';
const TASK_FINISH = 'SERVER:TASK::FINISH';
const EVENT_AFTER_REQUEST = 'SERVER:REQUEST:AFTER:START';
const EVENT_BEFORE_REQUEST = 'SERVER:REQUEST:BEFORE:START';
@@ -58,7 +59,6 @@ class Event extends BaseObject
const SERVER_CLOSE = 'on close';
/**
* @param $name
* @param $callback