Documentation

TemporalPluginInterface extends ConnectionPluginInterface, ClientPluginInterface, ScheduleClientPluginInterface, WorkerPluginInterface

Combined plugin interface for bundles that configure connection, client, schedule client, and worker.

Implementing this interface is optional — plugins may implement only ConnectionPluginInterface, ClientPluginInterface, ScheduleClientPluginInterface, or WorkerPluginInterface as needed.

Table of Contents

Methods

configureClient()  : void
Modify client configuration before the client is created.
configureScheduleClient()  : void
Modify schedule client configuration before the client is created.
configureServiceClient()  : ServiceClientInterface
Modify the service client before it is used by the client.
configureWorker()  : void
Modify worker configuration before the worker is created.
configureWorkerFactory()  : void
Modify worker factory configuration before it is fully initialized.
getName()  : string
Unique name identifying this plugin (e.g., "my-org.tracing").
initializeWorker()  : void
Called after a worker is created, allowing plugins to register workflows, activities, and other components on the worker.
run()  : int
Wraps the worker factory run lifecycle using chain-of-responsibility.
runWorker()  : PromiseInterface

Methods

configureServiceClient()

Modify the service client before it is used by the client.

public configureServiceClient(ServiceClientInterface $serviceClient, callable(ServiceClientInterface): void $next) : ServiceClientInterface

Use this hook to configure connection-level settings such as API keys, gRPC metadata, auth tokens, or context options.

Parameters
$serviceClient : ServiceClientInterface
$next : callable(ServiceClientInterface): void

Calls the next plugin or the final hook.

Return values
ServiceClientInterface

getName()

Unique name identifying this plugin (e.g., "my-org.tracing").

public getName() : string

Used for deduplication and diagnostics.

Return values
string

initializeWorker()

Called after a worker is created, allowing plugins to register workflows, activities, and other components on the worker.

public initializeWorker(WorkerInterface $worker, callable(WorkerInterface): void $next) : void

This method is called in forward (registration) order immediately after the worker is created. This is the appropriate place for registrations because it is called before the worker starts polling.

Task queue name is available via WorkerInterface::getID().

Parameters
$worker : WorkerInterface
$next : callable(WorkerInterface): void

Calls the next plugin or the final hook.

run()

Wraps the worker factory run lifecycle using chain-of-responsibility.

public run(WorkerFactoryInterface $factory, callable(WorkerFactoryInterface): int $next) : int

Each plugin wraps the next one in the chain. The innermost call executes the actual processing loop. Plugins are chained in registration order: the first registered plugin is the outermost wrapper.

Use this to manage resources, add observability, or handle errors:

public function run(WorkerFactoryInterface $factory, callable $next): int
{
    $pool = new ConnectionPool();
    try {
        return $next($factory);
    } finally {
        $pool->close();
    }
}
Parameters
$factory : WorkerFactoryInterface
$next : callable(WorkerFactoryInterface): int

Calls the next plugin or the actual run loop.

Return values
int

        
On this page

Search results