| Total Complexity | 4 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 18 | class Selector implements Layered |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * rpc extra key for selected client |
||
| 22 | */ |
||
| 23 | public const CLI = '~v'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var Cluster |
||
| 27 | */ |
||
| 28 | private $cluster = null; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Selector constructor. |
||
| 32 | * @param Cluster $cluster |
||
| 33 | */ |
||
| 34 | public function __construct(Cluster $cluster) |
||
| 35 | { |
||
| 36 | $this->cluster = $cluster; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param Request $request |
||
| 41 | * @param Context $ctx |
||
| 42 | * @return Request |
||
| 43 | */ |
||
| 44 | public function inbound($request, Context $ctx) |
||
| 45 | { |
||
| 46 | $request->setExtra(self::CLI, $this->cluster->picking($request->server(), ...$request->getTags())); |
||
| 47 | return $request; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param Response $response |
||
| 52 | * @param Context $ctx |
||
| 53 | * @return Response |
||
| 54 | */ |
||
| 55 | public function outbound($response, Context $ctx) |
||
| 56 | { |
||
| 57 | return $response; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @param Throwable $e |
||
| 62 | * @param Context $ctx |
||
| 63 | * @throws Throwable |
||
| 64 | */ |
||
| 65 | public function exception(Throwable $e, Context $ctx) |
||
| 68 | } |
||
| 69 | } |
||
| 70 |