aboutsummaryrefslogtreecommitdiff
path: root/src/WorkerClient.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-03-02 20:31:10 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-03-02 20:31:10 +0300
commitc2639092c69695f72753caf7eec90716579a58c6 (patch)
tree94b16533d37313ba120b62f3ec56d356f035d979 /src/WorkerClient.php
parentc269f18cc8d77a939b74a4abaf886d5d423ff329 (diff)
create separate classes WorkerClient and MasterClient
Diffstat (limited to 'src/WorkerClient.php')
-rw-r--r--src/WorkerClient.php42
1 files changed, 42 insertions, 0 deletions
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