项目作者: limingxinleo

项目描述 :
与Swoft RPC Server通信的Client扩展
高级语言: PHP
项目地址: git://github.com/limingxinleo/swoft-rpc-client.git
创建时间: 2018-07-17T04:20:19Z
项目社区:https://github.com/limingxinleo/swoft-rpc-client

开源协议:

下载


swoft-rpc-client

Build Status

安装

  1. composer require limingxinleo/swoft-rpc-client

使用

定义客户端

  1. <?php
  2. namespace SwoftTest\Rpc\Testing\Clients;
  3. use SwoftTest\Rpc\Testing\Lib\DemoServiceInterface;
  4. use Swoftx\Rpc\Client\Client;
  5. /**
  6. * Class DemoService
  7. * @package SwoftTest\Rpc\Testing\Clients
  8. * @method version()
  9. */
  10. class DemoService extends Client
  11. {
  12. /** @var PoolName */
  13. protected $name = 'demo';
  14. /** @var Pool ip */
  15. protected $ip = '127.0.0.1';
  16. /** @var Pool port */
  17. protected $port = 8099;
  18. /** @var Service interface */
  19. protected $interface = DemoServiceInterface::class;
  20. }

复制服务提供方的接口

  1. <?php
  2. /**
  3. * Swoft Entity Cache
  4. *
  5. * @author limx <715557344@qq.com>
  6. * @link https://github.com/limingxinleo/swoft-rpc-client
  7. */
  8. namespace SwoftTest\Rpc\Testing\Lib;
  9. use Swoft\Core\ResultInterface;
  10. /**
  11. * Interface DemoServiceInterface
  12. * @package SwoftTest\Db\Testing\Lib
  13. * @method ResultInterface deferVersion()
  14. */
  15. interface DemoServiceInterface
  16. {
  17. public function version();
  18. }

调用

  1. <?php
  2. use SwoftTest\Rpc\Testing\Clients\DemoService;
  3. $client = DemoService::getInstance();
  4. echo $client->version();