如何使用

  1. /**
  2. * Class RpcController
  3. *
  4. * @since 2.0
  5. *
  6. * @Controller()
  7. */
  8. class RpcController
  9. {
  10. /**
  11. * @Reference(pool="user.pool")
  12. *
  13. * @var UserInterface
  14. */
  15. private $userService;
  16. /**
  17. * @Reference(pool="user.pool", version="1.2")
  18. *
  19. * @var UserInterface
  20. */
  21. private $userService2;
  22. /**
  23. * @RequestMapping("getList")
  24. *
  25. * @return array
  26. */
  27. public function getList(): array
  28. {
  29. $result = $this->userService->getList(12, 'type');
  30. $result2 = $this->userService2->getList(12, 'type');
  31. return [$result, $result2];
  32. }
  33. /**
  34. * @RequestMapping("returnBool")
  35. *
  36. * @return array
  37. */
  38. public function returnBool(): array
  39. {
  40. $result = $this->userService->delete(12);
  41. if (is_bool($result)) {
  42. return ['bool'];
  43. }
  44. return ['notBool'];
  45. }
  46. /**
  47. * @RequestMapping()
  48. *
  49. * @return array
  50. */
  51. public function bigString(): array
  52. {
  53. $string = $this->userService->getBigContent();
  54. return ['string'];
  55. }
  56. }

@Reference

  • pool 指定使用那个服务的连接池(使用那个服务)
  • version 指定服务的版本