Skip to content

MessageFactory doesn't seem to resolve #15

Description

@factormaarten

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:

<?php

namespace Database;

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;

class PhalconSQL implements ChildInterface
{
    private $phql;

    public static function create(Messenger $messenger, LoopInterface $loop)
    {
        $messenger->registerRpc('executeQuery', function (Payload $payload) {
            return resolve([
                'response' => 'works'
            ]);
        });
    }
}

Here's how I'm calling the rpc:

                    $loop = EventLoopFactory::create();
                    CpuCoreCountFlexible::createFromClass(PhalconSQL::class, $loop)->then(function (PoolInterface $pool) {
                        echo 'tack' . PHP_EOL;

                        $pool->rpc(
                            MessageFactory::rpc('executeQuery')
                        )->then(function (Payload $result){
                            echo $result['response'] . PHP_EOL;
                            $pool->terminate();
                        });

                        echo 'tock' . PHP_EOL;

                    });
                    $loop->run();

What should I change to make it all resolve?

Thanks so much!
Maarten

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions