Search by

switon / rpc

switon

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

v1.0.1 2026-08-22 14:25 UTC

This package is auto-updated.

Last update: 2026-11-23 14:28:24 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://github.com/switon-php/rpc/blob/main/docs/README.md

License

MIT.