{"id":15649145,"url":"https://github.com/wyrihaximus/reactphp-child-process-pool","last_synced_at":"2025-05-07T09:44:11.164Z","repository":{"id":31359699,"uuid":"34922583","full_name":"WyriHaximus/reactphp-child-process-pool","owner":"WyriHaximus","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-04T05:54:13.000Z","size":425,"stargazers_count":41,"open_issues_count":12,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-15T06:16:52.386Z","etag":null,"topics":["child-process","cpu-offload","hacktoberfest","php","reactphp"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WyriHaximus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"WyriHaximus"}},"created_at":"2015-05-01T20:28:02.000Z","updated_at":"2025-02-26T16:27:01.000Z","dependencies_parsed_at":"2024-06-18T15:20:11.474Z","dependency_job_id":"08df20d3-eab5-4af7-a1d5-1f2f85f6150b","html_url":"https://github.com/WyriHaximus/reactphp-child-process-pool","commit_stats":{"total_commits":356,"total_committers":13,"mean_commits":"27.384615384615383","dds":0.1123595505617978,"last_synced_commit":"1ad9bc8c00e2dbebdd9559f57175b6f8eb86ce27"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-child-process-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-child-process-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-child-process-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-child-process-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WyriHaximus","download_url":"https://codeload.github.com/WyriHaximus/reactphp-child-process-pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252853036,"owners_count":21814449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["child-process","cpu-offload","hacktoberfest","php","reactphp"],"created_at":"2024-10-03T12:28:16.881Z","updated_at":"2025-05-07T09:44:11.141Z","avatar_url":"https://github.com/WyriHaximus.png","language":"PHP","funding_links":["https://github.com/sponsors/WyriHaximus"],"categories":[],"sub_categories":[],"readme":"# Pool wyrihaximus/react-child-process-messenger processes\n\n[![Linux Build Status](https://travis-ci.org/WyriHaximus/reactphp-child-process-pool.png)](https://travis-ci.org/WyriHaximus/reactphp-child-process-pool)\n[![Latest Stable Version](https://poser.pugx.org/WyriHaximus/react-child-process-pool/v/stable.png)](https://packagist.org/packages/WyriHaximus/react-child-process-pool)\n[![Total Downloads](https://poser.pugx.org/wyrihaximus/react-child-process-pool/downloads.png)](https://packagist.org/packages/wyrihaximus/react-child-process-pool)\n[![Code Coverage](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-child-process-pool/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/WyriHaximus/react-child-process-pool/?branch=master)\n[![License](https://poser.pugx.org/wyrihaximus/react-child-process-pool/license.png)](https://packagist.org/packages/wyrihaximus/react-child-process-pool)\n[![PHP 7 ready](http://php7ready.timesplinter.ch/WyriHaximus/reactphp-child-process-pool/badge.svg)](https://travis-ci.org/WyriHaximus/reactphp-child-process-pool)\n\n## Installation ##\n\nTo install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `~`.\n\n```\ncomposer require wyrihaximus/react-child-process-pool\n```\n\n## Pools ##\n\n* `Dummy` - Meant for testing, doesn't do anything but complies to it's contract\n* `Fixed` - Spawns a given fixed amount of workers\n* `Flexible` - Spawns workers as a needed basis, given a minimum and maximum it will spawn within those values\n\n## Usage ##\n\nThis package pools [`wyrihaximus/react-child-process-messenger`](https://github.com/WyriHaximus/reactphp-child-process-messenger), for basic messaging please see that package for details how to use it.\n\n## Creating a pool ##\n\nThis package ships with a set factories, which create different pools. (All the options in the following examples are the default options.)\n\n### Dummy ###\n\nCreates a `Dummy` pool:\n\n```php\n$loop = EventLoopFactory::create();\n\nDummy::createFromClass(ReturnChild::class, $loop)-\u003ethen(function (PoolInterface $pool) {\n  // Now you have a Dummy pool, which does absolutely nothing\n});\n```\n\n### Fixed ###\n\nCreates a `Fixed` pool:\n\n```php\n$loop = EventLoopFactory::create();\n$options = [\n    Options::SIZE =\u003e 5,\n];\nFixed::createFromClass(ReturnChild::class, $loop, $options)-\u003ethen(function (PoolInterface $pool) {\n    // You now have a pull with 5 always running child processes \n});\n```\n\n### Flexible ###\n\nCreates a `Flexible` pool:\n\n```php\n$loop = EventLoopFactory::create();\n$options = [\n    Options::MIN_SIZE =\u003e 0,\n    Options::MAX_SIZE =\u003e 5,\n    Options::TTL      =\u003e 0,\n];\nFlexible::createFromClass(ReturnChild::class, $loop, $options)-\u003ethen(function (PoolInterface $pool) {\n    // You now have a pool that spawns no child processes on start.\n    // But when you call rpc a new child process will be started for \n    // as long as the pool has work in the queue. With a maximum of five.\n});\n```\n\n### CpuCoreCountFixed ###\n\nCreates a `Fixed` pool with size set to the number of CPU cores:\n\n```php\n$loop = EventLoopFactory::create();\n\nCpuCoreCountFlexible::createFromClass(ReturnChild::class, $loop)-\u003ethen(function (PoolInterface $pool) {\n    // You now have a Fixed pool with a child process assigned to each CPU core.\n});\n```\n\n### CpuCoreCountFlexible ###\n\nThe following example will creates a flexible pool with max size set to the number of CPU cores. Where the `create` method requires you to give it a `React\\ChildProcess\\Process`. The `createFromClass` lets you pass a classname of a class implementing [`WyriHaximus\\React\\ChildProcess\\Messenger\\ChildInterface`](https://github.com/WyriHaximus/reactphp-child-process-messenger/blob/master/src/ChildInterface.php) that will be used as the worker in the client. Take a look at [`WyriHaximus\\React\\ChildProcess\\Messenger\\ReturnChild`](https://github.com/WyriHaximus/reactphp-child-process-messenger/blob/master/src/ReturnChild.php) to see how that works.\n\n```php\n$loop = EventLoopFactory::create();\n\nCpuCoreCountFlexible::createFromClass(ReturnChild::class, $loop)-\u003ethen(function (PoolInterface $pool) {\n    // You now have a Fixed pool with a child process assigned to each CPU core,\n    // which, just like the Flexible pool, will only run when there is something\n    // in the queue.\n});\n```\n\n## License ##\n\nCopyright 2017 [Cees-Jan Kiewiet](http://wyrihaximus.net/)\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n\n### Contributors beyond the commit log\n* Gabi Davila - Helping test if my github token will be secure for pull requests on AppVeyor\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyrihaximus%2Freactphp-child-process-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwyrihaximus%2Freactphp-child-process-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyrihaximus%2Freactphp-child-process-pool/lists"}