wyrihaximus / react-child-process-messenger
Messenger decorator for react/child-process
Fund package maintenance!
WyriHaximus
Installs: 249 207
Dependents: 6
Suggesters: 0
Security: 0
Stars: 31
Watchers: 5
Forks: 14
Open Issues: 23
Requires
- php: ^8 || ^7.4
- ext-hash: ^8 || ^7.4
- ext-json: ^8 || ^7.4
- cakephp/utility: ^4.2.4
- doctrine/inflector: ^2.0.3
- evenement/evenement: ^3.0.1
- paragonie/random_compat: ^9.0 || ^2.0
- react/child-process: ^0.6.2
- react/event-loop: ^1.1.1
- react/promise: ^2.8
- react/promise-stream: ^1.2
- react/promise-timer: ^1.6
- react/socket: ^1.6
- thecodingmachine/safe: ^1.3.3
- wyrihaximus/composer-update-bin-autoload-path: ^1.1.1
- wyrihaximus/constants: ^1.6
- wyrihaximus/file-descriptors: ^1.1
- wyrihaximus/json-throwable: ^4.1
- wyrihaximus/ticking-promise: ^2 || ^3
Requires (Dev)
- wyrihaximus/async-test-utilities: ^3.4.18
- 5.x-dev
- 4.x-dev
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.x-dev
- 3.1.0
- 3.0.0
- 2.10.x-dev
- 2.10.1
- 2.10.0
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.0
- dev-renovate/major-phpstan-packages
- dev-renovate/cakephp-utility-5.x
- dev-renovate/cakephp-utility-4.x
- dev-renovate/symfony
- dev-renovate/react-socket-1.x
- dev-renovate/wyrihaximus-async-test-utilities-8.x
- dev-renovate/react-promise-timer-1.x
- dev-renovate/react-promise-3.x
- dev-renovate/thecodingmachine-safe-2.x
- dev-renovate/react-promise-stream-1.x
- dev-renovate/react-promise-2.x
- dev-renovate/react-event-loop-1.x
- dev-renovate/wyrihaximus-file-descriptors-1.x
- dev-renovate/react-child-process-0.x
- dev-renovate/evenement-evenement-3.x
- dev-renovate/doctrine-inflector-2.x
- dev-dependabot/composer/composer/composer-1.10.27
- dev-Ditch-Dependabot
- dev-master
- dev-4.x-shouldn't-require-vendor.php-but-autoload.php
- dev-handle-handshake-errors-child-side
- dev-close-all-fds-before-spawning-process
- dev-send-handshake-after-settingup-timeout
- dev-child-connect-to-parent-time-out
- dev-child-process.php-stop-loop-on-errors-from-child-factory
- dev-child-process-0.5
- dev-var.ci
- dev-ci-travis-osx-builds
This package is auto-updated.
Last update: 2024-11-12 14:49:04 UTC
README
Plain messages and RPC style wrapper around react/child-process
. For pooling messengers take a look at wyrihaximus/react-child-process-pool
Installation
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ~
.
composer require wyrihaximus/react-child-process-messenger
Hassle less Example
While this package supports several ways of setting up communication between parent and child the simplest way is to create class implementing WyriHaximus\React\ChildProcess\Messenger\ChildInterface
. Up on calling create
everything is set up and created to handle supported RPC
's and messages.
<?php use React\EventLoop\LoopInterface; use WyriHaximus\React\ChildProcess\Messenger\ChildInterface; use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload; use function React\Promise\resolve; final class ExampleChild implements ChildInterface { public static function create(Messenger $messenger, LoopInterface $loop) { $messenger->registerRpc('example', function (Payload $payload) { return resolve($payload->getPayload()); }); } }
On the parent side you only need to call to spawn a child running that class:
MessengerFactory::parentFromClass('ExampleChild', $loop)->then(static function (Messenger $messenger): void { $messenger->rpc(/* etc etc */); });
More Examples
For both message and RPC examples see the examples directory
Contributing
Please see CONTRIBUTING for details.
License
Copyright 2021 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.