| Total Complexity | 7 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class Linker |
||
| 20 | { |
||
| 21 | use SAR; |
||
| 22 | |||
| 23 | // node joining |
||
| 24 | public const ACT_JOIN = 0xE1; |
||
| 25 | |||
| 26 | // node leaving |
||
| 27 | public const ACT_LEAVE = 0xE9; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var Pool |
||
| 31 | */ |
||
| 32 | private $pool = null; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var Nsqd |
||
| 36 | */ |
||
| 37 | private $nsqd = null; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Linker constructor. |
||
| 41 | * @param Endpoint $endpoint |
||
| 42 | * @param Consuming $consuming |
||
| 43 | */ |
||
| 44 | public function __construct(Endpoint $endpoint, Consuming $consuming = null) |
||
| 45 | { |
||
| 46 | if (is_null($consuming)) { |
||
| 47 | $this->pool = new Pool(new Options, function () use ($endpoint) { |
||
| 48 | return new Nsqd($endpoint); |
||
| 49 | }, "nsqd:{$endpoint->service()}"); |
||
| 50 | } else { |
||
| 51 | $this->nsqd = new Nsqd($endpoint, $consuming); |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return Promised |
||
| 57 | */ |
||
| 58 | public function connect() : Promised |
||
| 59 | { |
||
| 60 | return $this->pool ? Promise::resolved() : $this->nsqd->connect(); |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @return Promised |
||
| 65 | */ |
||
| 66 | public function disconnect() : Promised |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param string $name |
||
| 73 | * @param array $arguments |
||
| 74 | * @return mixed |
||
| 75 | */ |
||
| 76 | public function __call(string $name, array $arguments) |
||
| 79 | } |
||
| 80 | } |
||
| 81 |