Download the PHP package riki137/multitron without Composer
On this page you can find all versions of the php package riki137/multitron. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download riki137/multitron
More information about riki137/multitron
Files in riki137/multitron
Package multitron
Short Description Tool for managing fast both asynchronous and multi-threaded execution of tasks. Focused on performance and pleasant CLI interface.
License MIT
Informations about the package multitron
Multitron
Multitron is a PHP-based task orchestration and execution library designed to efficiently run and manage complex task trees. It's designed to handle parallel task execution, inter-process communication, and resource management.
⚠️ This library is still in early development and may have breaking changes in the future. However, it is already being used in production and actively developed.
Features
- Task orchestration and dependency management
- Concurrent execution with configurable task concurrency
- Real-time progress updates and logging
- Support for task partitioning and advanced routing
- Shared memory and inter-process communication via channels and semaphores
- Error handling and logging using PSR-3 and Tracy
Installation
Multitron can be installed using Composer:
Usage
Basic Task Tree
Define your custom tasks by implementing the Task
interface or extending the SimpleTask
abstract class. Inject these tasks into a task tree using a dependency injection container.
Running the Task Tree
To run the task tree, ...
Error Logging
Configure error handling by using either a PSR-3 logger or Tracy for detailed error reports.
PSR-3 Logger
Tracy
Progress Reporting and Logging
Multitron provides real-time logging and progress updates that can be configured using the provided classes.
Task Partitioning
Partition tasks to run chunks of tasks in parallel, each of which operates on a subset of data.
Central Cache with TaskCommunicator
The Central Cache in Multitron offers a global shared memory space for tasks to read and write data efficiently across different task instances.
This functionality is facilitated through the TaskCommunicator
, which serves as an intermediary for these operations within the execute
method of a task.
Operations Provided by TaskCommunicator
Within the context of a task's execution, the TaskCommunicator
provides four key methods that interact with the Central Cache:
-
$comm->read(string $key): ?array
This method allows a task to read data from the Central Cache associated with the specified key. If the key exists, it retrieves the corresponding data and returns it as an array. If the key does not exist, it returns
null
. -
$comm->readSubset(string $key, array $subkeys): ?array
This method reads a subset of the data stored under a specified key. It takes a key and an array of subkeys. It retrieves data for each of the provided subkeys if they exist, returning an associative array containing the subkeys and their corresponding values. If any subkey is not found, it will simply omit them from the result.
-
$comm->write(string $key, array &$data): Future
This method allows tasks to write or update data in the Central Cache associated with a specified key. It takes the key and a reference to the data array to be stored. The method asynchronously writes the data and returns a
Future
, allowing the task to continue execution without blocking. -
$comm->merge(string $key, array $data, int $level = 1): Future
The
merge
method is used to merge new data into the existing data structure under a specified key in the Central Cache. It takes a key, the data to merge, and an optional merge level indicating how deep the array structure should be merged. This is particularly useful for hierarchical or nested data structures.
Contributing
Contributions, issues, and feature requests are welcome!
Feel free to check issues page if you want to contribute.
License
Multitron is licensed under the MIT License. See the LICENSE file for more details.
All versions of multitron with dependencies
ext-pcntl Version *
ext-mbstring Version *
symfony/console Version ^5.4|^6.0|^7.0
amphp/parallel Version ^2.2
amphp/sync Version ^2.2