This commit is contained in:
2023-12-12 15:35:34 +08:00
parent 4ebb7e9686
commit 92e65c4abd
15 changed files with 362 additions and 391 deletions
+8 -21
View File
@@ -46,10 +46,7 @@ class AsyncServer implements ServerInterface
* @param array $service * @param array $service
* @param int $daemon * @param int $daemon
* @return void * @return void
* @throws ConfigException * @throws
* @throws ContainerExceptionInterface
* @throws NotFindClassException
* @throws NotFoundExceptionInterface
*/ */
public function initCoreServers(array $service, int $daemon = 0): void public function initCoreServers(array $service, int $daemon = 0): void
{ {
@@ -67,7 +64,7 @@ class AsyncServer implements ServerInterface
/** /**
* @return bool * @return bool
* @throws ReflectionException * @throws
*/ */
public function shutdown(): bool public function shutdown(): bool
{ {
@@ -83,10 +80,7 @@ class AsyncServer implements ServerInterface
* @param SConfig $config * @param SConfig $config
* @param int $daemon * @param int $daemon
* @return void * @return void
* @throws ConfigException * @throws
* @throws ContainerExceptionInterface
* @throws NotFindClassException
* @throws NotFoundExceptionInterface
*/ */
private function createBaseServer(SConfig $config, int $daemon = 0): void private function createBaseServer(SConfig $config, int $daemon = 0): void
{ {
@@ -106,9 +100,7 @@ class AsyncServer implements ServerInterface
* @param $config * @param $config
* @param $daemon * @param $daemon
* @return void * @return void
* @throws ConfigException * @throws
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/ */
private function initServer($match, $config, $daemon): void private function initServer($match, $config, $daemon): void
{ {
@@ -139,8 +131,7 @@ class AsyncServer implements ServerInterface
* @param SConfig $config * @param SConfig $config
* @param int $daemon * @param int $daemon
* @return array * @return array
* @throws Exception * @throws
* @throws ConfigException
*/ */
protected function systemConfig(SConfig $config, int $daemon): array protected function systemConfig(SConfig $config, int $daemon): array
{ {
@@ -158,9 +149,7 @@ class AsyncServer implements ServerInterface
/** /**
* @param SConfig $config * @param SConfig $config
* @return void * @return void
* @throws ContainerExceptionInterface * @throws
* @throws NotFoundExceptionInterface
* @throws Exception
*/ */
public function addListener(SConfig $config): void public function addListener(SConfig $config): void
{ {
@@ -177,8 +166,7 @@ class AsyncServer implements ServerInterface
/** /**
* @param SConfig $config * @param SConfig $config
* @return void * @return void
* @throws ContainerExceptionInterface * @throws
* @throws NotFoundExceptionInterface
*/ */
protected function _listenDump(SConfig $config): void protected function _listenDump(SConfig $config): void
{ {
@@ -220,8 +208,7 @@ class AsyncServer implements ServerInterface
* @param Server\Port|Server $base * @param Server\Port|Server $base
* @param array $events * @param array $events
* @return void * @return void
* @throws ContainerExceptionInterface * @throws
* @throws NotFoundExceptionInterface
*/ */
private function onEventListen(Server\Port|Server $base, array $events): void private function onEventListen(Server\Port|Server $base, array $events): void
{ {
+1 -2
View File
@@ -43,7 +43,6 @@ class ProcessManager extends Component
/** /**
* @param OnServerBeforeStart $beforeStart * @param OnServerBeforeStart $beforeStart
* @return void * @return void
* @throws ReflectionException
*/ */
public function OnServerBeforeStart(OnServerBeforeStart $beforeStart): void public function OnServerBeforeStart(OnServerBeforeStart $beforeStart): void
{ {
@@ -71,7 +70,7 @@ class ProcessManager extends Component
/** /**
* @param string|OnProcessInterface|BaseProcess $custom * @param string|OnProcessInterface|BaseProcess $custom
* @throws Exception * @throws
*/ */
public function add(string|OnProcessInterface|BaseProcess $custom): void public function add(string|OnProcessInterface|BaseProcess $custom): void
{ {
+1 -5
View File
@@ -4,10 +4,6 @@
namespace Kiri\Server\Abstracts; namespace Kiri\Server\Abstracts;
use Exception;
use Kiri;
/** /**
* Class Server * Class Server
* @package Server\Abstracts * @package Server\Abstracts
@@ -17,7 +13,7 @@ abstract class Server
/** /**
* Server constructor. * Server constructor.
* @throws Exception * @throws
*/ */
public function __construct() public function __construct()
{ {
+2 -3
View File
@@ -21,7 +21,6 @@ trait TraitServer
private array $_process = []; private array $_process = [];
/** /**
* @var StdoutLogger * @var StdoutLogger
*/ */
@@ -32,7 +31,7 @@ trait TraitServer
/** /**
* @param string|array|BaseProcess $class * @param string|array|BaseProcess $class
* @return void * @return void
* @throws Exception * @throws
*/ */
public function addProcess(string|array|BaseProcess $class): void public function addProcess(string|array|BaseProcess $class): void
{ {
@@ -69,7 +68,7 @@ trait TraitServer
/** /**
* @return void * @return void
* @throws Exception * @throws
*/ */
public function onSignal(): void public function onSignal(): void
{ {
+111 -111
View File
@@ -11,123 +11,123 @@ namespace Kiri\Server;
class Constant class Constant
{ {
const START = 'Start'; const string START = 'Start';
const SHUTDOWN = 'Shutdown'; const string SHUTDOWN = 'Shutdown';
const BEFORE_SHUTDOWN = 'beforeShutdown'; const string BEFORE_SHUTDOWN = 'beforeShutdown';
const WORKER_START = 'WorkerStart'; const string WORKER_START = 'WorkerStart';
const WORKER_STOP = 'WorkerStop'; const string WORKER_STOP = 'WorkerStop';
const WORKER_EXIT = 'WorkerExit'; const string WORKER_EXIT = 'WorkerExit';
const CONNECT = 'Connect'; const string CONNECT = 'Connect';
const HANDSHAKE = 'handshake'; const string HANDSHAKE = 'handshake';
const OPEN = 'open'; const string OPEN = 'open';
const DISCONNECT = 'disconnect'; const string DISCONNECT = 'disconnect';
const MESSAGE = 'message'; const string MESSAGE = 'message';
const RECEIVE = 'Receive'; const string RECEIVE = 'Receive';
const PACKET = 'Packet'; const string PACKET = 'Packet';
const REQUEST = 'request'; const string REQUEST = 'request';
const CLOSE = 'Close'; const string CLOSE = 'Close';
const TASK = 'Task'; const string TASK = 'Task';
const FINISH = 'Finish'; const string FINISH = 'Finish';
const PIPE_MESSAGE = 'PipeMessage'; const string PIPE_MESSAGE = 'PipeMessage';
const WORKER_ERROR = 'WorkerError'; const string WORKER_ERROR = 'WorkerError';
const MANAGER_START = 'ManagerStart'; const string MANAGER_START = 'ManagerStart';
const MANAGER_STOP = 'ManagerStop'; const string MANAGER_STOP = 'ManagerStop';
const BEFORE_RELOAD = 'BeforeReload'; const string BEFORE_RELOAD = 'BeforeReload';
const AFTER_RELOAD = 'AfterReload'; const string AFTER_RELOAD = 'AfterReload';
const SERVER_TYPE_HTTP = 'http'; const string SERVER_TYPE_HTTP = 'http';
const SERVER_TYPE_WEBSOCKET = 'ws'; const string SERVER_TYPE_WEBSOCKET = 'ws';
const SERVER_TYPE_TCP = 'tcp'; const string SERVER_TYPE_TCP = 'tcp';
const SERVER_TYPE_UDP = 'udp'; const string SERVER_TYPE_UDP = 'udp';
const SERVER_TYPE_BASE = 'base'; const string SERVER_TYPE_BASE = 'base';
const STATUS_404_MESSAGE = '<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>'; const string STATUS_404_MESSAGE = '<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>';
const STATUS_405_MESSAGE = '<h2>HTTP 405 Method allow</h2><hr><i>Powered by Swoole</i>'; const string STATUS_405_MESSAGE = '<h2>HTTP 405 Method allow</h2><hr><i>Powered by Swoole</i>';
const OPTION_REACTOR_NUM = 'reactor_num'; const string OPTION_REACTOR_NUM = 'reactor_num';
const OPTION_WORKER_NUM = 'worker_num'; const string OPTION_WORKER_NUM = 'worker_num';
const OPTION_MAX_REQUEST = 'max_request'; const string OPTION_MAX_REQUEST = 'max_request';
const OPTION_MAX_CONN = 'max_connection'; const string OPTION_MAX_CONN = 'max_connection';
const OPTION_TASK_WORKER_NUM = 'task_worker_num'; const string OPTION_TASK_WORKER_NUM = 'task_worker_num';
const OPTION_TASK_IPC_MODE = 'task_ipc_mode'; const string OPTION_TASK_IPC_MODE = 'task_ipc_mode';
const OPTION_TASK_MAX_REQUEST = 'task_max_request'; const string OPTION_TASK_MAX_REQUEST = 'task_max_request';
const OPTION_TASK_TMPDIR = 'task_tmpdir'; const string OPTION_TASK_TMPDIR = 'task_tmpdir';
const OPTION_TASK_ENABLE_COROUTINE = 'task_enable_coroutine'; const string OPTION_TASK_ENABLE_COROUTINE = 'task_enable_coroutine';
const OPTION_TASK_USE_OBJECT = 'task_use_object'; const string OPTION_TASK_USE_OBJECT = 'task_use_object';
const OPTION_DISPATCH_MODE = 'dispatch_mode'; const string OPTION_DISPATCH_MODE = 'dispatch_mode';
const OPTION_DISPATCH_FUNC = 'dispatch_func'; const string OPTION_DISPATCH_FUNC = 'dispatch_func';
const OPTION_MESSAGE_QUEUE_KEY = 'message_queue_key'; const string OPTION_MESSAGE_QUEUE_KEY = 'message_queue_key';
const OPTION_DAEMONIZE = 'daemonize'; const string OPTION_DAEMONIZE = 'daemonize';
const OPTION_BACKLOG = 'backlog'; const string OPTION_BACKLOG = 'backlog';
const OPTION_LOG_FILE = 'log_file'; const string OPTION_LOG_FILE = 'log_file';
const OPTION_LOG_LEVEL = 'log_level'; const string OPTION_LOG_LEVEL = 'log_level';
const OPTION_LOG_DATE_WITH_MICROSECONDS = 'log_date_with_microseconds'; const string OPTION_LOG_DATE_WITH_MICROSECONDS = 'log_date_with_microseconds';
const OPTION_LOG_ROTATION = 'log_rotation'; const string OPTION_LOG_ROTATION = 'log_rotation';
const OPTION_LOG_DATE_FORMAT = 'log_date_format'; const string OPTION_LOG_DATE_FORMAT = 'log_date_format';
const OPTION_OPEN_TCP_KEEPALIVE = 'open_tcp_keepalive'; const string OPTION_OPEN_TCP_KEEPALIVE = 'open_tcp_keepalive';
const OPTION_HEARTBEAT_CHECK_INTERVAL = 'heartbeat_check_interval'; const string OPTION_HEARTBEAT_CHECK_INTERVAL = 'heartbeat_check_interval';
const OPTION_HEARTBEAT_IDLE_TIME = 'heartbeat_idle_time'; const string OPTION_HEARTBEAT_IDLE_TIME = 'heartbeat_idle_time';
const OPTION_OPEN_EOF_CHECK = 'open_eof_check'; const string OPTION_OPEN_EOF_CHECK = 'open_eof_check';
const OPTION_OPEN_EOF_SPLIT = 'open_eof_split'; const string OPTION_OPEN_EOF_SPLIT = 'open_eof_split';
const OPTION_PACKAGE_EOF = 'package_eof'; const string OPTION_PACKAGE_EOF = 'package_eof';
const OPTION_OPEN_LENGTH_CHECK = 'open_length_check'; const string OPTION_OPEN_LENGTH_CHECK = 'open_length_check';
const OPTION_PACKAGE_LENGTH_TYPE = 'package_length_type'; const string OPTION_PACKAGE_LENGTH_TYPE = 'package_length_type';
const OPTION_PACKAGE_LENGTH_FUNC = 'package_length_func'; const string OPTION_PACKAGE_LENGTH_FUNC = 'package_length_func';
const OPTION_PACKAGE_MAX_LENGTH = 'package_max_length'; const string OPTION_PACKAGE_MAX_LENGTH = 'package_max_length';
const OPTION_OPEN_HTTP_PROTOCOL = 'open_http_protocol'; const string OPTION_OPEN_HTTP_PROTOCOL = 'open_http_protocol';
const OPTION_OPEN_MQTT_PROTOCOL = 'open_mqtt_protocol'; const string OPTION_OPEN_MQTT_PROTOCOL = 'open_mqtt_protocol';
const OPTION_OPEN_REDIS_PROTOCOL = 'open_redis_protocol'; const string OPTION_OPEN_REDIS_PROTOCOL = 'open_redis_protocol';
const OPTION_OPEN_WEBSOCKET_PROTOCOL = 'open_websocket_protocol'; const string OPTION_OPEN_WEBSOCKET_PROTOCOL = 'open_websocket_protocol';
const OPTION_OPEN_WEBSOCKET_CLOSE_FRAME = 'open_websocket_close_frame'; const string OPTION_OPEN_WEBSOCKET_CLOSE_FRAME = 'open_websocket_close_frame';
const OPTION_OPEN_TCP_NODELAY = 'open_tcp_nodelay'; const string OPTION_OPEN_TCP_NODELAY = 'open_tcp_nodelay';
const OPTION_OPEN_CPU_AFFINITY = 'open_cpu_affinity'; const string OPTION_OPEN_CPU_AFFINITY = 'open_cpu_affinity';
const OPTION_CPU_AFFINITY_IGNORE = 'cpu_affinity_ignore'; const string OPTION_CPU_AFFINITY_IGNORE = 'cpu_affinity_ignore';
const OPTION_TCP_DEFER_ACCEPT = 'tcp_defer_accept'; const string OPTION_TCP_DEFER_ACCEPT = 'tcp_defer_accept';
const OPTION_SSL_CERT_FILE = 'ssl_cert_file'; const string OPTION_SSL_CERT_FILE = 'ssl_cert_file';
const OPTION_SSL_KEY_FILE = 'ssl_key_file'; const string OPTION_SSL_KEY_FILE = 'ssl_key_file';
const OPTION_SSL_METHOD = 'ssl_method'; const string OPTION_SSL_METHOD = 'ssl_method';
const OPTION_SSL_PROTOCOLS = 'ssl_protocols'; const string OPTION_SSL_PROTOCOLS = 'ssl_protocols';
const OPTION_SSL_SNI_CERTS = 'ssl_sni_certs'; const string OPTION_SSL_SNI_CERTS = 'ssl_sni_certs';
const OPTION_SSL_CIPHERS = 'ssl_ciphers'; const string OPTION_SSL_CIPHERS = 'ssl_ciphers';
const OPTION_SSL_VERIFY_PEER = 'ssl_verify_peer'; const string OPTION_SSL_VERIFY_PEER = 'ssl_verify_peer';
const OPTION_SSL_ALLOW_SELF_SIGNED = 'ssl_allow_self_signed'; const string OPTION_SSL_ALLOW_SELF_SIGNED = 'ssl_allow_self_signed';
const OPTION_SSL_CLIENT_CERT_FILE = 'ssl_client_cert_file'; const string OPTION_SSL_CLIENT_CERT_FILE = 'ssl_client_cert_file';
const OPTION_SSL_COMPRESS = 'ssl_compress'; const string OPTION_SSL_COMPRESS = 'ssl_compress';
const OPTION_SSL_VERIFY_DEPTH = 'ssl_verify_depth'; const string OPTION_SSL_VERIFY_DEPTH = 'ssl_verify_depth';
const OPTION_SSL_PREFER_SERVER_CIPHERS = 'ssl_prefer_server_ciphers'; const string OPTION_SSL_PREFER_SERVER_CIPHERS = 'ssl_prefer_server_ciphers';
const OPTION_SSL_DHPARAM = 'ssl_dhparam'; const string OPTION_SSL_DHPARAM = 'ssl_dhparam';
const OPTION_SSL_ECDH_CURVE = 'ssl_ecdh_curve'; const string OPTION_SSL_ECDH_CURVE = 'ssl_ecdh_curve';
const OPTION_USER = 'user'; const string OPTION_USER = 'user';
const OPTION_GROUP = 'group'; const string OPTION_GROUP = 'group';
const OPTION_CHROOT = 'chroot'; const string OPTION_CHROOT = 'chroot';
const OPTION_PID_FILE = 'pid_file'; const string OPTION_PID_FILE = 'pid_file';
const OPTION_BUFFER_INPUT_SIZE = 'buffer_input_size'; const string OPTION_BUFFER_INPUT_SIZE = 'buffer_input_size';
const OPTION_BUFFER_OUTPUT_SIZE = 'buffer_output_size'; const string OPTION_BUFFER_OUTPUT_SIZE = 'buffer_output_size';
const OPTION_SOCKET_BUFFER_SIZE = 'socket_buffer_size'; const string OPTION_SOCKET_BUFFER_SIZE = 'socket_buffer_size';
const OPTION_ENABLE_UNSAFE_EVENT = 'enable_unsafe_event'; const string OPTION_ENABLE_UNSAFE_EVENT = 'enable_unsafe_event';
const OPTION_DISCARD_TIMEOUT_REQUEST = 'discard_timeout_request'; const string OPTION_DISCARD_TIMEOUT_REQUEST = 'discard_timeout_request';
const OPTION_ENABLE_REUSE_PORT = 'enable_reuse_port'; const string OPTION_ENABLE_REUSE_PORT = 'enable_reuse_port';
const OPTION_ENABLE_DELAY_RECEIVE = 'enable_delay_receive'; const string OPTION_ENABLE_DELAY_RECEIVE = 'enable_delay_receive';
const OPTION_RELOAD_ASYNC = 'reload_async'; const string OPTION_RELOAD_ASYNC = 'reload_async';
const OPTION_MAX_WAIT_TIME = 'max_wait_time'; const string OPTION_MAX_WAIT_TIME = 'max_wait_time';
const OPTION_TCP_FASTOPEN = 'tcp_fastopen'; const string OPTION_TCP_FASTOPEN = 'tcp_fastopen';
const OPTION_REQUEST_SLOWLOG_FILE = 'request_slowlog_file'; const string OPTION_REQUEST_SLOWLOG_FILE = 'request_slowlog_file';
const OPTION_ENABLE_COROUTINE = 'enable_coroutine'; const string OPTION_ENABLE_COROUTINE = 'enable_coroutine';
const OPTION_MAX_COROUTINE = 'max_coroutine'; const string OPTION_MAX_COROUTINE = 'max_coroutine';
const OPTION_SEND_YIELD = 'send_yield'; const string OPTION_SEND_YIELD = 'send_yield';
const OPTION_SEND_TIMEOUT = 'send_timeout'; const string OPTION_SEND_TIMEOUT = 'send_timeout';
const OPTION_HOOK_FLAGS = 'hook_flags'; const string OPTION_HOOK_FLAGS = 'hook_flags';
const OPTION_BUFFER_HIGH_WATERMARK = 'buffer_high_watermark'; const string OPTION_BUFFER_HIGH_WATERMARK = 'buffer_high_watermark';
const OPTION_BUFFER_LOW_WATERMARK = 'buffer_low_watermark'; const string OPTION_BUFFER_LOW_WATERMARK = 'buffer_low_watermark';
const OPTION_TCP_USER_TIMEOUT = 'tcp_user_timeout'; const string OPTION_TCP_USER_TIMEOUT = 'tcp_user_timeout';
const OPTION_STATS_FILE = 'stats_file'; const string OPTION_STATS_FILE = 'stats_file';
const OPTION_EVENT_OBJECT = 'event_object'; const string OPTION_EVENT_OBJECT = 'event_object';
const OPTION_START_SESSION_ID = 'start_session_id'; const string OPTION_START_SESSION_ID = 'start_session_id';
const OPTION_SINGLE_THREAD = 'single_thread'; const string OPTION_SINGLE_THREAD = 'single_thread';
const OPTION_MAX_QUEUED_BYTES = 'max_queued_bytes'; const string OPTION_MAX_QUEUED_BYTES = 'max_queued_bytes';
} }
+1 -2
View File
@@ -13,12 +13,11 @@ class OnPipeMessage extends Server
{ {
/** /**
* @param \Swoole\Server $server * @param \Swoole\Server $server
* @param int $src_worker_id * @param int $src_worker_id
* @param mixed $message * @param mixed $message
* @throws Exception * @throws
*/ */
public function onPipeMessage(\Swoole\Server $server, int $src_worker_id, mixed $message): void public function onPipeMessage(\Swoole\Server $server, int $src_worker_id, mixed $message): void
{ {
+2 -4
View File
@@ -61,9 +61,7 @@ class OnRequest implements OnRequestInterface
* @param ResponseInterface $response * @param ResponseInterface $response
* @param ContainerInterface $container * @param ContainerInterface $container
* @param DataGrip $dataGrip * @param DataGrip $dataGrip
* @throws ContainerExceptionInterface * @throws
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/ */
public function __construct(public ResponseInterface $response, public ContainerInterface $container, public function __construct(public ResponseInterface $response, public ContainerInterface $container,
public DataGrip $dataGrip) public DataGrip $dataGrip)
@@ -81,7 +79,7 @@ class OnRequest implements OnRequestInterface
/** /**
* @param Request $request * @param Request $request
* @param Response $response * @param Response $response
* @throws Exception * @throws
*/ */
public function onRequest(Request $request, Response $response): void public function onRequest(Request $request, Response $response): void
{ {
+2 -2
View File
@@ -31,7 +31,7 @@ class OnServer extends Server
/** /**
* @param SServer $server * @param SServer $server
* @throws ReflectionException * @throws
*/ */
public function onStart(SServer $server): void public function onStart(SServer $server): void
{ {
@@ -45,7 +45,7 @@ class OnServer extends Server
/** /**
* @param SServer $server * @param SServer $server
* @throws ReflectionException * @throws
*/ */
public function onBeforeShutdown(SServer $server): void public function onBeforeShutdown(SServer $server): void
{ {
+2 -2
View File
@@ -19,7 +19,7 @@ class OnServerManager extends Server
/** /**
* @param \Swoole\Server $server * @param \Swoole\Server $server
* @throws ReflectionException * @throws
*/ */
public function onManagerStart(\Swoole\Server $server): void public function onManagerStart(\Swoole\Server $server): void
{ {
@@ -32,7 +32,7 @@ class OnServerManager extends Server
/** /**
* @param \Swoole\Server $server * @param \Swoole\Server $server
* @return void * @return void
* @throws ReflectionException * @throws
*/ */
public function onManagerStop(\Swoole\Server $server): void public function onManagerStop(\Swoole\Server $server): void
{ {
+5 -5
View File
@@ -64,7 +64,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
* @param Server $server * @param Server $server
* @param int $workerId * @param int $workerId
* @return void * @return void
* @throws Exception * @throws
*/ */
public function onWorkerStart(Server $server, int $workerId): void public function onWorkerStart(Server $server, int $workerId): void
{ {
@@ -92,7 +92,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
/** /**
* @param Server $server * @param Server $server
* @param int $workerId * @param int $workerId
* @throws ReflectionException * @throws
*/ */
public function onWorkerStop(Server $server, int $workerId): void public function onWorkerStop(Server $server, int $workerId): void
{ {
@@ -104,7 +104,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
/** /**
* @param Server $server * @param Server $server
* @param int $workerId * @param int $workerId
* @throws ReflectionException * @throws
*/ */
public function onWorkerExit(Server $server, int $workerId): void public function onWorkerExit(Server $server, int $workerId): void
{ {
@@ -118,7 +118,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
* @param int $worker_pid * @param int $worker_pid
* @param int $exit_code * @param int $exit_code
* @param int $signal * @param int $signal
* @throws Exception * @throws
*/ */
public function onWorkerError(Server $server, int $worker_id, int $worker_pid, int $exit_code, int $signal): void public function onWorkerError(Server $server, int $worker_id, int $worker_pid, int $exit_code, int $signal): void
{ {
@@ -135,7 +135,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
/** /**
* @param $messageContent * @param $messageContent
* @throws Exception * @throws
*/ */
protected function system_mail($messageContent): void protected function system_mail($messageContent): void
{ {
+12 -12
View File
@@ -68,7 +68,7 @@ class HotReload extends BaseProcess
/** /**
* @param $data * @param $data
* @return void * @return void
* @throws Exception * @throws
*/ */
public function onStop($data): void public function onStop($data): void
{ {
@@ -85,7 +85,7 @@ class HotReload extends BaseProcess
/** /**
* @param Process|null $process * @param Process|null $process
* @return void * @return void
* @throws Exception * @throws
*/ */
public function process(?Process $process): void public function process(?Process $process): void
{ {
@@ -101,7 +101,7 @@ class HotReload extends BaseProcess
/** /**
* @return void * @return void
* @throws Exception * @throws
*/ */
private function onCrontabReload(): void private function onCrontabReload(): void
{ {
@@ -112,7 +112,7 @@ class HotReload extends BaseProcess
/** /**
* @return void * @return void
* @throws Exception * @throws
*/ */
private function onInotifyReload(): void private function onInotifyReload(): void
{ {
@@ -133,7 +133,7 @@ class HotReload extends BaseProcess
/** /**
* @param bool $isReload * @param bool $isReload
* @throws Exception * @throws
*/ */
private function loadDirs(bool $isReload = false): void private function loadDirs(bool $isReload = false): void
{ {
@@ -150,7 +150,7 @@ class HotReload extends BaseProcess
/** /**
* @throws Exception * @throws
*/ */
public function tick(): void public function tick(): void
{ {
@@ -176,7 +176,7 @@ class HotReload extends BaseProcess
* @param $path * @param $path
* @param bool $isReload * @param bool $isReload
* @return void * @return void
* @throws Exception * @throws
*/ */
private function loadByDir($path, bool $isReload = false): void private function loadByDir($path, bool $isReload = false): void
{ {
@@ -262,7 +262,7 @@ class HotReload extends BaseProcess
} }
/** /**
* @throws Exception * @throws
*/ */
public function reload(): void public function reload(): void
{ {
@@ -278,7 +278,7 @@ class HotReload extends BaseProcess
} }
/** /**
* @throws Exception * @throws
*/ */
public function timerReload(): void public function timerReload(): void
{ {
@@ -297,7 +297,7 @@ class HotReload extends BaseProcess
/** /**
* 重启 * 重启
* @throws Exception * @throws
*/ */
public function trigger_reload(): void public function trigger_reload(): void
{ {
@@ -307,7 +307,7 @@ class HotReload extends BaseProcess
/** /**
* @throws Exception * @throws
*/ */
public function clearWatch(): void public function clearWatch(): void
{ {
@@ -325,7 +325,7 @@ class HotReload extends BaseProcess
/** /**
* @param $dir * @param $dir
* @return bool * @return bool
* @throws Exception * @throws
*/ */
public function watch($dir): bool public function watch($dir): bool
{ {
+3 -4
View File
@@ -66,7 +66,7 @@ class ServerCommand extends Command
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return int * @return int
* @throws Exception * @throws
*/ */
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
@@ -83,7 +83,7 @@ class ServerCommand extends Command
/** /**
* @param InputInterface $input * @param InputInterface $input
* @return int * @return int
* @throws ReflectionException * @throws
*/ */
protected function restart(InputInterface $input): int protected function restart(InputInterface $input): int
{ {
@@ -95,8 +95,7 @@ class ServerCommand extends Command
/** /**
* @return int * @return int
* @throws ReflectionException * @throws
* @throws Exception
*/ */
protected function stop(): int protected function stop(): int
{ {
+1 -4
View File
@@ -5,8 +5,6 @@ namespace Kiri\Server;
use Kiri\Abstracts\Providers; use Kiri\Abstracts\Providers;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
/** /**
@@ -18,8 +16,7 @@ class ServerProviders extends Providers
/** /**
* @throws ContainerExceptionInterface * @throws
* @throws NotFoundExceptionInterface
*/ */
public function onImport(): void public function onImport(): void
{ {
+2 -3
View File
@@ -2,7 +2,6 @@
namespace Kiri\Server; namespace Kiri\Server;
use Exception;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
use Kiri\Server\Abstracts\TraitServer; use Kiri\Server\Abstracts\TraitServer;
use Swoole\Process; use Swoole\Process;
@@ -28,7 +27,7 @@ class State extends Component
/** /**
* @return bool * @return bool
* @throws Exception * @throws
*/ */
public function isRunner(): bool public function isRunner(): bool
{ {
@@ -44,7 +43,7 @@ class State extends Component
/** /**
* @param $port * @param $port
* @throws Exception * @throws
*/ */
public function exit($port): void public function exit($port): void
{ {
+2 -4
View File
@@ -3,10 +3,8 @@
namespace Kiri\Server\Task; namespace Kiri\Server\Task;
use Exception;
use Kiri; use Kiri;
use Kiri\Server\Constant; use Kiri\Server\Constant;
use ReflectionException;
use Swoole\Server; use Swoole\Server;
/** /**
@@ -37,7 +35,7 @@ class Task
* @param int $task_id * @param int $task_id
* @param mixed $data * @param mixed $data
* @return void * @return void
* @throws ReflectionException * @throws
*/ */
public function onFinish(Server $server, int $task_id, mixed $data): void public function onFinish(Server $server, int $task_id, mixed $data): void
{ {
@@ -51,7 +49,7 @@ class Task
* @param int $src_worker_id * @param int $src_worker_id
* @param mixed $data * @param mixed $data
* @return mixed * @return mixed
* @throws ReflectionException|Exception * @throws
*/ */
public function onTask(Server $server, int $task_id, int $src_worker_id, mixed $data): mixed public function onTask(Server $server, int $task_id, int $src_worker_id, mixed $data): mixed
{ {