switon/rpc

Queue-backed synchronous request-reply calls between PHP handlers for Switon Framework

Maintainers

Package info

github.com/switon-php/rpc

Documentation

pkg:composer/switon/rpc

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 04:55:54 UTC


README

CI PHP 8.3+

Switon's queue-backed request-reply RPC for mapped method calls, daemon workers, and reply/error handling.

Highlights

  • Request-reply flow: RpcInterface::call() sends one request and waits for the matching reply.
  • Method mapping: RPC names can target methods or configured aliases.
  • Daemon worker: requests can be pulled from a queue and dispatched by the invoker.
  • Clear failure types: timeout, remote, protocol, and method failures are separated.
  • Queue-backed transport: request handling is built around queued work.

Installation

composer require switon/rpc

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Rpc\RpcInterface;

class UserService
{
    #[Autowired] protected RpcInterface $rpc;

    public function profile(int $userId): array
    {
        return $this->rpc->call(UserProfileService::class . '::profile', ['userId' => $userId]);
    }
}

class UserProfileService
{
    public function profile(int $userId): array
    {
        return ['id' => $userId, 'name' => 'mark'];
    }
}

Docs: https://docs.switon.dev/latest/rpc

License

MIT.