Skip to content

Aquarmini/swoft-rpc-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swoft-rpc-client

Build Status

安装

composer require limingxinleo/swoft-rpc-client

使用

定义客户端

<?php
namespace SwoftTest\Rpc\Testing\Clients;

use SwoftTest\Rpc\Testing\Lib\DemoServiceInterface;
use Swoftx\Rpc\Client\Client;

/**
 * Class DemoService
 * @package SwoftTest\Rpc\Testing\Clients
 * @method version()
 */
class DemoService extends Client
{
    /** @var PoolName */
    protected $name = 'demo';

    /** @var Pool ip */
    protected $ip = '127.0.0.1';

    /** @var Pool port */
    protected $port = 8099;

    /** @var Service interface */
    protected $interface = DemoServiceInterface::class;
}

复制服务提供方的接口

<?php
/**
 * Swoft Entity Cache
 *
 * @author   limx <715557344@qq.com>
 * @link     https://github.com/limingxinleo/swoft-rpc-client
 */
namespace SwoftTest\Rpc\Testing\Lib;

use Swoft\Core\ResultInterface;

/**
 * Interface DemoServiceInterface
 * @package SwoftTest\Db\Testing\Lib
 * @method ResultInterface deferVersion()
 */
interface DemoServiceInterface
{
    public function version();
}

调用

<?php
use SwoftTest\Rpc\Testing\Clients\DemoService;

$client = DemoService::getInstance();
echo $client->version();

About

与Swoft RPC Server通信的Client扩展

Resources

Stars

Watchers

Forks

Packages

No packages published