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上发起拉取请求的安全性