Nexus API Reference

SwooleThreadConfig
in package

Read onlyYes
FinalYes
Tags
psalm-api

Immutable configuration for SwooleThreadServer::run(). Constructed via the static bind() entry; further tunables return new instances via PHP 8.5 clone-with.

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

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
self

enableWebSocket()

public enableWebSocket([bool $b = true ]) : self
Parameters
$b : bool = true
Return values
self

installSignalHandlers()

public installSignalHandlers(bool $b) : self
Parameters
$b : bool
Return values
self

logger()

public logger(LoggerInterface $log) : self
Parameters
$log : LoggerInterface
Return values
self

maxRequest()

public maxRequest(int $n) : self
Parameters
$n : int
Return values
self

threads()

public threads(int $n) : self
Parameters
$n : int
Return values
self

withLogQueue()

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
self

withSwooleSetting()

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>
Return values
self
On this page

Search results