diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-03-02 20:31:10 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-03-02 20:31:10 +0300 |
commit | c2639092c69695f72753caf7eec90716579a58c6 (patch) | |
tree | 94b16533d37313ba120b62f3ec56d356f035d979 /src | |
parent | c269f18cc8d77a939b74a4abaf886d5d423ff329 (diff) |
create separate classes WorkerClient and MasterClient
Diffstat (limited to 'src')
-rw-r--r-- | src/Client.php | 42 | ||||
-rw-r--r-- | src/MasterClient.php | 30 | ||||
-rw-r--r-- | src/WorkerClient.php | 42 |
3 files changed, 72 insertions, 42 deletions
diff --git a/src/Client.php b/src/Client.php index 7146f5a..33228d1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -55,48 +55,6 @@ class Client { } /** - * @param array $targets - * @return ResponseMessage - * @throws \Exception - */ - public function poke(array $targets) { - return $this->recv( - $this->sendRequest(new RequestMessage('poke', ['targets' => $targets])) - ); - } - - /** - * @return ResponseMessage - * @throws \Exception - */ - public function status() { - return $this->recv( - $this->sendRequest(new RequestMessage('status')) - ); - } - - /** - * @param array $targets - * @return ResponseMessage - * @throws \Exception - */ - public function poll(array $targets) { - return $this->recv( - $this->sendRequest(new RequestMessage('poll', ['targets' => $targets])) - ); - } - - /** - * @param int $id - * @return ResponseMessage - */ - public function runManual(int $id) { - return $this->recv( - $this->sendRequest(new RequestMessage('run-manual', ['id' => $id])) - ); - } - - /** * @param RequestMessage $request * @return int */ diff --git a/src/MasterClient.php b/src/MasterClient.php new file mode 100644 index 0000000..6a7902b --- /dev/null +++ b/src/MasterClient.php @@ -0,0 +1,30 @@ +<?php + +namespace jobd; + +class MasterClient extends Client { + + /** + * @param array $targets + * @return ResponseMessage + * @throws \Exception + */ + public function poke(array $targets): ResponseMessage + { + return $this->recv( + $this->sendRequest(new RequestMessage('poke', ['targets' => $targets])) + ); + } + + /** + * @return ResponseMessage + * @throws \Exception + */ + public function status(): ResponseMessage + { + return $this->recv( + $this->sendRequest(new RequestMessage('status')) + ); + } + +}
\ No newline at end of file diff --git a/src/WorkerClient.php b/src/WorkerClient.php new file mode 100644 index 0000000..4e221df --- /dev/null +++ b/src/WorkerClient.php @@ -0,0 +1,42 @@ +<?php + +namespace jobd; + +class WorkerClient extends Client { + + /** + * @return ResponseMessage + * @throws \Exception + */ + public function status(): ResponseMessage + { + return $this->recv( + $this->sendRequest(new RequestMessage('status')) + ); + } + + /** + * @param string[] $targets + * @return ResponseMessage + * @throws \Exception + */ + public function poll(array $targets): ResponseMessage + { + return $this->recv( + $this->sendRequest(new RequestMessage('poll', ['targets' => $targets])) + ); + } + + /** + * @param int[] $ids + * @return ResponseMessage + * @throws \Exception + */ + public function runManual(array $ids): ResponseMessage + { + return $this->recv( + $this->sendRequest(new RequestMessage('run-manual', ['ids' => $ids])) + ); + } + +}
\ No newline at end of file |