wyrihaximus / react-child-process-pool
处理 wyrihaximus/react-child-process-messenger 进程池
Requires
- php: ^8.0 || ^7.0 || ^5.4
- evenement/evenement: ^3.0 || ^2.0
- react/event-loop: ^1.1
- wyrihaximus/cpu-core-detector: ^2 || ^1.0.2
- wyrihaximus/file-descriptors: ^2 || ^1.0 || ^0.1
- wyrihaximus/react-child-process-messenger: ^4 || ^3 || ^2.10.1
- wyrihaximus/ticking-promise: ^2 || ^1.5
Requires (Dev)
- clue/block-react: ^1.3
- phake/phake: ^2.2.1
- phpunit/phpunit: ^4.8.35||^5.0||^9.5
- squizlabs/php_codesniffer: ^3.3.2
- vectorface/dunit: ~2.0
Suggests
- wyrihaximus/react-child-process-pool-redis-queue: Redis RPC queue
- dev-master
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.0
- v1.1.x-dev
- 1.1.1
- 1.1.0
- v1.0.x-dev
- 1.0.1
- 1.0.0
- 1.0.0-beta5
- 1.0.0-beta4
- 1.0.0-beta3
- 1.0.0-beta2
- 1.0.0-beta1
- 1.0.0-alpha11
- 1.0.0-alpha10
- 1.0.0-alpha9
- 1.0.0-alpha8
- 1.0.0-alpha7
- 1.0.0-alpha6
- 1.0.0-alpha5
- 1.0.0-alpha4
- 1.0.0-alpha3
- 1.0.0-alpha2
- 1.0.0-alpha1
- dev-renovate/configure
- dev-dependabot/composer/clue/block-react-1.5.0
- dev-split-up-tests-and-benchmark-into-two-different-jobs
- dev-spawnfailure
- dev-feature-up-and-down-scaling-pool
- dev-var.ci
This package is auto-updated.
Last update: 2024-09-04 07:18:59 UTC
README
安装
要通过 Composer 安装,请使用以下命令,它将自动检测最新版本并将其与 ~
绑定。
composer require wyrihaximus/react-child-process-pool
池
Dummy
- 用于测试,不执行任何操作,但符合其合约Fixed
- 启动指定数量的工作进程Flexible
- 根据需要启动工作进程,给定最小值和最大值,将在这些值内启动
用法
此包汇集了 wyrihaximus/react-child-process-messenger
,有关基本消息传递的详细信息,请参阅该包,了解如何使用它。
创建池
此包附带一组工厂,用于创建不同的池。(以下示例中的所有选项都是默认选项。)
Dummy
创建一个 Dummy
池
$loop = EventLoopFactory::create(); Dummy::createFromClass(ReturnChild::class, $loop)->then(function (PoolInterface $pool) { // Now you have a Dummy pool, which does absolutely nothing });
Fixed
创建一个 Fixed
池
$loop = EventLoopFactory::create(); $options = [ Options::SIZE => 5, ]; Fixed::createFromClass(ReturnChild::class, $loop, $options)->then(function (PoolInterface $pool) { // You now have a pull with 5 always running child processes });
Flexible
创建一个 Flexible
池
$loop = EventLoopFactory::create(); $options = [ Options::MIN_SIZE => 0, Options::MAX_SIZE => 5, Options::TTL => 0, ]; Flexible::createFromClass(ReturnChild::class, $loop, $options)->then(function (PoolInterface $pool) { // You now have a pool that spawns no child processes on start. // But when you call rpc a new child process will be started for // as long as the pool has work in the queue. With a maximum of five. });
CpuCoreCountFixed
创建一个大小设置为CPU核心数的 Fixed
池
$loop = EventLoopFactory::create(); CpuCoreCountFlexible::createFromClass(ReturnChild::class, $loop)->then(function (PoolInterface $pool) { // You now have a Fixed pool with a child process assigned to each CPU core. });
CpuCoreCountFlexible
以下示例将创建一个最大大小设置为CPU核心数的灵活池。其中,create
方法需要您提供 React\ChildProcess\Process
。 createFromClass
允许您传递实现 WyriHaximus\React\ChildProcess\Messenger\ChildInterface
的类的名称,该类将作为客户端中的工作进程使用。请参阅 WyriHaximus\React\ChildProcess\Messenger\ReturnChild
以了解其工作原理。
$loop = EventLoopFactory::create(); CpuCoreCountFlexible::createFromClass(ReturnChild::class, $loop)->then(function (PoolInterface $pool) { // You now have a Fixed pool with a child process assigned to each CPU core, // which, just like the Flexible pool, will only run when there is something // in the queue. });
许可
版权所有 2017 Cees-Jan Kiewiet
特此授予任何获得此软件及其相关文档文件(“软件”)副本的任何人免费使用该软件的权利,不受任何限制,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向提供软件的人授予此类权利,前提是以下条件
上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和无侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论此类责任是基于合同、侵权或其他方式产生,与软件或软件的使用或其他交易有关。
提交日志之外的贡献者
- Gabi Davila - 帮助测试我的github令牌在AppVeyor上的pull请求安全性