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

}