summaryrefslogtreecommitdiff
path: root/src/MasterClient.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-04-13 02:14:53 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-04-13 02:14:53 +0300
commitd0fa8d6f63003a6cb2f1897158bc587ab2344ea3 (patch)
tree5a6c165e928354a59eea48030c5de51067d381e4 /src/MasterClient.php
parent5272c5f541a75b2a7824df4264ad7e69c6e346fa (diff)
1.6.0: support signals
Diffstat (limited to 'src/MasterClient.php')
-rw-r--r--src/MasterClient.php39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/MasterClient.php b/src/MasterClient.php
index d85e454..2fed338 100644
--- a/src/MasterClient.php
+++ b/src/MasterClient.php
@@ -2,6 +2,10 @@
namespace jobd;
+use jobd\exceptions\JobdException;
+use jobd\messages\RequestMessage;
+use jobd\messages\ResponseMessage;
+
class MasterClient extends Client {
public function __construct(int $port = Client::MASTER_PORT, ...$args)
@@ -12,7 +16,7 @@ class MasterClient extends Client {
/**
* @param array $targets
* @return ResponseMessage
- * @throws Exception
+ * @throws JobdException
*/
public function poke(array $targets): ResponseMessage
{
@@ -24,7 +28,7 @@ class MasterClient extends Client {
/**
* @param bool $poll_workers
* @return ResponseMessage
- * @throws Exception
+ * @throws JobdException
*/
public function status(bool $poll_workers = false): ResponseMessage
{
@@ -36,7 +40,7 @@ class MasterClient extends Client {
/**
* @param array[] $jobs
* @return ResponseMessage
- * @throws Exception
+ * @throws JobdException
*/
public function runManual(array $jobs): ResponseMessage
{
@@ -45,4 +49,33 @@ class MasterClient extends Client {
);
}
+ /**
+ * @param int $job_id
+ * @param int $signal
+ * @param string $target
+ * @return ResponseMessage
+ * @throws JobdException
+ */
+ public function sendSignal(int $job_id, int $signal, string $target): ResponseMessage
+ {
+ return $this->sendSignals([
+ [
+ 'id' => $job_id,
+ 'signal' => $signal,
+ 'target' => $target
+ ]
+ ]);
+ }
+
+ /**
+ * @param array $data
+ * @return ResponseMessage
+ * @throws JobdException
+ */
+ public function sendSignals(array $data): ResponseMessage {
+ return $this->recv(
+ $this->sendRequest(new RequestMessage('send-signal', ['jobs' => $data]))
+ );
+ }
+
} \ No newline at end of file