class Server implements ServerInterface

Properties

protected Server|null $server
protected array $onRequestCallbacks

Methods

__construct(Container $container, LoggerInterface $logger, Dispatcher $eventDispatcher)

No description

init(ServerConfig $config)

Initialize the server with the given configuration.

void
start()

Start the server.

Server
getServer()

Get the underlying Swoole server instance.

void
initServers(ServerConfig $config)

Initialize all server ports from the configuration.

array
sortServers(array $servers)

Sort servers so websocket/http servers are initialized first.

Server
makeServer(int $type, string $host, int $port, int $mode, int $sockType)

Create the appropriate Swoole server instance based on type.

void
registerSwooleEvents(Port|Server $server, array $events, string $serverName)

Register Swoole event callbacks on the server or port.

guardResponseCallback(callable $callback)

Guard a native response callback from escaping its transport boundary.

guardWorkerDeliveryCallback(callable $callback)

Guard an inter-worker delivery callback from escaping its transport boundary.

void
reportCallbackFailure(Throwable $throwable)

Report a callback failure without escaping the native boundary.

array
defaultCallbacks()

Get the default server callbacks for the bootstrap lifecycle.

Details

at line 34
__construct(Container $container, LoggerInterface $logger, Dispatcher $eventDispatcher)

No description

Parameters

Container $container
LoggerInterface $logger
Dispatcher $eventDispatcher

at line 44
ServerInterface init(ServerConfig $config)

Initialize the server with the given configuration.

Boot-only. Mutates the underlying Swoole server and registered callbacks; runtime use races with active workers and request handling.

Parameters

ServerConfig $config

Return Value

ServerInterface

at line 54
void start()

Start the server.

Return Value

void

at line 67
Server getServer()

Get the underlying Swoole server instance.

Return Value

Server

at line 75
protected void initServers(ServerConfig $config)

Initialize all server ports from the configuration.

Parameters

ServerConfig $config

Return Value

void

at line 127
protected array sortServers(array $servers)

Sort servers so websocket/http servers are initialized first.

Parameters

array $servers

Return Value

array

at line 155
protected Server makeServer(int $type, string $host, int $port, int $mode, int $sockType)

Create the appropriate Swoole server instance based on type.

Parameters

int $type
string $host
int $port
int $mode
int $sockType

Return Value

Server

at line 172
protected void registerSwooleEvents(Port|Server $server, array $events, string $serverName)

Register Swoole event callbacks on the server or port.

Parameters

Port|Server $server
array $events
string $serverName

Return Value

void

at line 221
protected Closure guardResponseCallback(callable $callback)

Guard a native response callback from escaping its transport boundary.

Parameters

callable $callback

Return Value

Closure

at line 247
protected Closure guardWorkerDeliveryCallback(callable $callback)

Guard an inter-worker delivery callback from escaping its transport boundary.

The source ID is the sending worker ID for pipe messages and the task ID for task results.

Parameters

callable $callback

Return Value

Closure

at line 262
protected void reportCallbackFailure(Throwable $throwable)

Report a callback failure without escaping the native boundary.

Parameters

Throwable $throwable

Return Value

void

at line 277
protected array defaultCallbacks()

Get the default server callbacks for the bootstrap lifecycle.

Return Value

array