-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessageFactory doesn't seem to resolve #15
Comments
I too would be interested in the solution here |
Could you replace the |
I've tried that, but it's not giving any errors unfortunately |
That is weird, there should always be something. I'll run your code tonight and see if it works on my end |
With some minor edits it works: $loop = EventLoopFactory::create();
CpuCoreCountFlexible::createFromClass(PhalconSQL::class, $loop)->done(function (PoolInterface $pool) {
echo 'tack' . PHP_EOL;
$pool->rpc(
MessagesFactory::rpc('executeQuery')
)->done(function (Payload $result) use ($pool) {
echo $result['response'] . PHP_EOL;
$pool->terminate();
});
echo 'tock' . PHP_EOL;
});
$loop->run(); |
Thanks for the response. This is what's happening: I start the loop, it echo's tack, it echo's tock and after that it keeps waiting for $result['response'] use React\EventLoop\LoopInterface;
use WyriHaximus\React\ChildProcess\Messenger\ChildInterface;
use WyriHaximus\React\ChildProcess\Messenger\Messenger;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;
use function React\Promise\resolve;
final class ReturnChild implements ChildInterface
{
public static function create(Messenger $messenger, LoopInterface $loop)
{
$messenger->registerRpc('executeQuery', function (Payload $payload) {
return resolve([
'response' => 'works'
]);
});
}
} I don't see anything going wrong here. As I see it the promise should resolve. |
I'll set up a repo somewhere this weekend that has your code working |
Hey @mpjraaij just set up a repository at https://github.com/WyriHaximus/shiny-octo-adventure run |
Thanks a lot! I'll go over it this week and see if it works :) if not I'll send you an email. |
👍 |
Hi @WyriHaximus Also tried this on different environments: eventloopserver.php Flexible::createFromClass(LoopChildProcess::class, $loop)
->then(function (PoolInterface $pool) {
echo 'tack', PHP_EOL;
for ($i = 0; $i < 100; $i++) {
//echo $i, PHP_EOL;
$pool->rpc(
MessagesFactory::rpc(
'return',
[
'i' => $i,
'time' => time(),
//'string' => str_pad('0', 1024 * 1024 * 5)
'string' => str_pad('0', 5)
]
)
)->then(function (Payload $payload) use ($pool) {
echo $payload['i'], PHP_EOL;
echo $payload['time'], PHP_EOL;
if ($payload['i'] == 99) {
$pool->terminate();
}
var_export($pool->info());
});
}
echo 'tock', PHP_EOL;
});
$loop->run(); I also replaced the The LoopChildProcess has no namespace and is required the eventloopserver.php. But the weird thing is everything works perfectly fine if I use: Flexible::createFromClass('WyriHaximus\React\ChildProcess\Messenger\ReturnChild', $loop) Anything I'm misunderstanding about the usage? Thanks for the help in advance. |
hey @cluigDE silly question but is |
No, the file containing the class was just included in the file eventloopserver.php Didn't thought of autoloading the class in composer. Will do that. Thanks. |
Hi Cees-Jan,
I'm trying to get the pool running, but something isn't adding up for me. This is the class I'm calling:
Here's how I'm calling the rpc:
What should I change to make it all resolve?
Thanks so much!
Maarten
The text was updated successfully, but these errors were encountered: