aboutsummaryrefslogtreecommitdiff
path: root/src/MasterClient.php
blob: d85e454d0ec6a53902d3939b7816a5cbe09a4d62 (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
48
<?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]))
        );
    }

}