SwooleThreadConfig
in package
Read onlyYes
FinalYes
Tags
Table of Contents
Properties
- $enableWebSocket : bool
- $host : string
- $installSignalHandlers : bool
- $logger : LoggerInterface
- $logQueue : Queue|null
- $maxRequest : 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
- 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.
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
$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 ][, 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
- $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
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>