Nexus API Reference

WorkerPoolBootstrap
in package

FinalYes
Tags
psalm-api

Entry point for a Swoole thread-based worker pool.

Creates N worker threads, each running an independent ActorSystem. Workers communicate via Thread\Queue (one queue per worker as inbox) and share a Thread\Map as the actor directory.

Usage: // Class-based handler: WorkerPoolBootstrap::create(WorkerPoolConfig::withThreads(8)) ->withHandler(MyApp::class) ->run();

// WorkerPool DSL (passes serialized closure):
WorkerPoolBootstrap::create(WorkerPoolConfig::withThreads(8))
    ->withSerializedConfigure($serialized)
    ->run();

Table of Contents

Methods

create()  : self
run()  : void
Start the worker pool. Blocks until the pool exits.
withHandler()  : self
withLoggerClass()  : self
withOnStart()  : self
Register a main-thread callback to run after all workers are ready.
withSerializedConfigure()  : self
Serialized opis/closure configure callable. When set, WorkerRunnable runs this instead of the WorkerStartHandler.
withSerializedLoggerFactory()  : self
Serialized opis/closure factory: Closure(): LoggerInterface.

Methods

withHandler()

public withHandler(WorkerStartHandler> $handlerClass) : self
Parameters
$handlerClass : WorkerStartHandler>
Return values
self

withLoggerClass()

public withLoggerClass(LoggerInterface>|null $loggerClass) : self
Parameters
$loggerClass : LoggerInterface>|null
Return values
self

withOnStart()

Register a main-thread callback to run after all workers are ready.

public withOnStart(callable(WorkerPoolHandle): void|null $onStart) : self

When set, raw Swoole\Thread instances are used instead of Thread\Pool so the main thread can invoke the callback while workers are running.

Parameters
$onStart : callable(WorkerPoolHandle): void|null
Return values
self

withSerializedConfigure()

Serialized opis/closure configure callable. When set, WorkerRunnable runs this instead of the WorkerStartHandler.

public withSerializedConfigure(string|null $serializedConfigure) : self
Parameters
$serializedConfigure : string|null
Return values
self

withSerializedLoggerFactory()

Serialized opis/closure factory: Closure(): LoggerInterface.

public withSerializedLoggerFactory(string|null $serializedLoggerFactory) : self
Parameters
$serializedLoggerFactory : string|null
Return values
self

        
On this page

Search results