SwooleThreadConfig
in package
Tags
Table of Contents
Constants
- DEFAULT_MAX_REQUEST_BODY_BYTES : int = 8 * 1024 * 1024
- Default maximum HTTP request package size: 8 MiB.
Properties
- $enableWebSocket : bool
- $host : string
- $installSignalHandlers : bool
- $logger : LoggerInterface
- $logQueue : Queue|null
- $maxRequest : int
- $maxRequestBodyBytes : int
- $port : int
- $shutdownTimeout : Duration
- $swooleSettings : array<string|int, mixed>
- $threads : int
Methods
- __construct() : mixed
- bind() : self
- enableWebSocket() : self
- installSignalHandlers() : self
- logger() : self
- maxRequest() : self
- maxRequestBodyBytes() : self
- Cap the maximum HTTP request package size (bytes). Swoole rejects a larger request at the protocol parser — before PHP materializes the body — for every method and both known-length and chunked bodies. Wired to Swoole's native `package_max_length`.
- shutdownTimeout() : self
- threads() : self
- withLogQueue() : self
- Pass a pre-allocated Swoole\Thread\Queue to be shared across all worker threads. Threads access it via Swoole\Thread::getArguments()[3].
- withSwooleSetting() : self
- Merge arbitrary Swoole server settings into the `$server->set([...])` call. Use for tcp_nodelay, tcp_defer_accept, socket_buffer_size, backlog, etc. — see website/docs/http/performance.md for the full list.
Constants
DEFAULT_MAX_REQUEST_BODY_BYTES
Default maximum HTTP request package size: 8 MiB.
public
int
DEFAULT_MAX_REQUEST_BODY_BYTES
= 8 * 1024 * 1024
Properties
$enableWebSocket
public
bool
$enableWebSocket
$host
public
string
$host
$installSignalHandlers
public
bool
$installSignalHandlers
$logger
public
LoggerInterface
$logger
$logQueue
public
Queue|null
$logQueue
= null
$maxRequest
public
int
$maxRequest
$maxRequestBodyBytes
public
int
$maxRequestBodyBytes
= self::DEFAULT_MAX_REQUEST_BODY_BYTES
$port
public
int
$port
$shutdownTimeout
public
Duration
$shutdownTimeout
$swooleSettings
public
array<string|int, mixed>
$swooleSettings
= []
$threads
public
int
$threads
Methods
__construct()
public
__construct(string $host, int $port, int $threads, int $maxRequest, Duration $shutdownTimeout, bool $installSignalHandlers, LoggerInterface $logger, bool $enableWebSocket[, Queue|null $logQueue = null ][, int $maxRequestBodyBytes = self::DEFAULT_MAX_REQUEST_BODY_BYTES ][, array<string, mixed> $swooleSettings = [] ]) : mixed
Parameters
- $host : string
- $port : int
- $threads : int
- $maxRequest : int
- $shutdownTimeout : Duration
- $installSignalHandlers : bool
- $logger : LoggerInterface
- $enableWebSocket : bool
- $logQueue : Queue|null = null
- $maxRequestBodyBytes : int = self::DEFAULT_MAX_REQUEST_BODY_BYTES
- $swooleSettings : array<string, mixed> = []
bind()
public
static bind(string $host[, int $port = 8080 ]) : self
Parameters
- $host : string
- $port : int = 8080
Return values
selfenableWebSocket()
public
enableWebSocket([bool $b = true ]) : self
Parameters
- $b : bool = true
Return values
selfinstallSignalHandlers()
public
installSignalHandlers(bool $b) : self
Parameters
- $b : bool
Return values
selflogger()
public
logger(LoggerInterface $log) : self
Parameters
- $log : LoggerInterface
Return values
selfmaxRequest()
public
maxRequest(int $n) : self
Parameters
- $n : int
Return values
selfmaxRequestBodyBytes()
Cap the maximum HTTP request package size (bytes). Swoole rejects a larger request at the protocol parser — before PHP materializes the body — for every method and both known-length and chunked bodies. Wired to Swoole's native `package_max_length`.
public
maxRequestBodyBytes(int $bytes) : self
Parameters
- $bytes : int
Return values
selfshutdownTimeout()
public
shutdownTimeout(Duration $d) : self
Parameters
- $d : Duration
Return values
selfthreads()
public
threads(int $n) : self
Parameters
- $n : int
Return values
selfwithLogQueue()
Pass a pre-allocated Swoole\Thread\Queue to be shared across all worker threads. Threads access it via Swoole\Thread::getArguments()[3].
public
withLogQueue(Queue $queue) : self
Pair with ThreadQueueHandler + a dedicated writer thread for lock-free file logging at high throughput.
Parameters
- $queue : Queue
Return values
selfwithSwooleSetting()
Merge arbitrary Swoole server settings into the `$server->set([...])` call. Use for tcp_nodelay, tcp_defer_accept, socket_buffer_size, backlog, etc. — see website/docs/http/performance.md for the full list.
public
withSwooleSetting(array<string, mixed> $settings) : self
Framework-controlled keys (max_request, worker_num, init_arguments) always win; user settings can't override them.
Parameters
- $settings : array<string, mixed>