Skip to content

v1.1.0

Choose a tag to compare

@matthi4s matthi4s released this 11 Dec 18:20
· 23 commits to master since this release
2875a4f

Added init tasks

You can now define tasks that are executed on every worker instance before the first task is executed.
This is helpful to run some initial setup or (in case of the ForkWorker)
to clear some variables that are inherited from the parent process, e.g. database connections.

// init tasks are always provided by a task factory
$taskmaster->setDefaultInitTaskFactory(new InitTaskFactory());

// but taskmaster can create task factories automatically by cloning or instancing a task
$taskmaster->setDefaultInitTask(new InitTask());
$taskmaster->setDefaultInitTask(InitTask::class);

// you can also define a task factory for a specific worker
$worker->setInitTaskFactory(new InitTaskFactory());