1 | <?php |
||
9 | class Writer implements WritableInterface |
||
10 | { |
||
11 | use WriterTrait; |
||
12 | |||
13 | private $httpClient; |
||
14 | private $options; |
||
15 | |||
16 | 27 | public function __construct(Client $httpClient, Options $options) |
|
21 | |||
22 | 19 | public function getOptions() |
|
26 | |||
27 | 16 | public function send(array $message) |
|
28 | { |
||
29 | $httpMessage = [ |
||
30 | 16 | "auth" => [$this->getOptions()->getUsername(), $this->getOptions()->getPassword()], |
|
31 | 'query' => [ |
||
32 | 16 | "db" => $this->getOptions()->getDatabase(), |
|
33 | 16 | "retentionPolicy" => $this->getOptions()->getRetentionPolicy(), |
|
34 | ], |
||
35 | 16 | "body" => $this->messageToLineProtocol($message, $this->getOptions()->getTags()) |
|
36 | ]; |
||
37 | |||
38 | 16 | $endpoint = $this->getHttpSeriesEndpoint(); |
|
39 | 16 | return $this->httpClient->post($endpoint, $httpMessage); |
|
40 | } |
||
41 | |||
42 | 19 | protected function getHttpSeriesEndpoint() |
|
46 | |||
47 | 19 | private function getHttpEndpoint($operation) |
|
60 | } |
||
61 |