summaryrefslogtreecommitdiff
path: root/src/MasterClient.php
blob: a804ce554c3d8ea5846ef36e9d5335ab46b4bbfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

namespace jobd;

class MasterClient extends Client {

    public function __construct(int $port = Client::MASTER_PORT, ...$args) {
        parent::__construct($port, ...$args);
    }

    /**
     * @param array $targets
     * @return ResponseMessage
     * @throws \Exception
     */
    public function poke(array $targets): ResponseMessage
    {
        return $this->recv(
            $this->sendRequest(new RequestMessage('poke', ['targets' => $targets]))
        );
    }

    /**
     * @param bool $poll_workers
     * @return ResponseMessage
     * @throws \Exception
     */
    public function status(bool $poll_workers = false): ResponseMessage
    {
        return $this->recv(
            $this->sendRequest(new RequestMessage('status', ['poll_workers' => $poll_workers]))
        );
    }

    /**
     * @param array[] $jobs
     * @return ResponseMessage
     * @throws \Exception
     */
    public function runManual(array $jobs): ResponseMessage
    {
        return $this->recv(
            $this->sendRequest(new RequestMessage('run-manual', ['jobs' => $jobs]))
        );
    }

}