|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Micro framework package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Stanislau Komar <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Micro\Plugin\Elastic\Configuration\Client; |
|
15
|
|
|
|
|
16
|
|
|
use Micro\Framework\Kernel\Configuration\PluginRoutingKeyConfiguration; |
|
17
|
|
|
use Micro\Plugin\Logger\Facade\LoggerFacadeInterface; |
|
18
|
|
|
|
|
19
|
|
|
class ElasticClientConfiguration extends PluginRoutingKeyConfiguration implements ElasticClientConfigurationInterface |
|
20
|
|
|
{ |
|
21
|
|
|
public const CFG_CLIENT_HOSTS = 'MICRO_ELASTIC_%s_HOSTS'; |
|
22
|
|
|
public const CFG_CLIENT_LOGGER = 'MICRO_ELASTIC_%s_LOGGER'; |
|
23
|
|
|
public const CFG_CLIENT_RETRIES = 'MICRO_ELASTIC_%s_RETRIES'; |
|
24
|
|
|
public const CFG_CLIENT_SSL_VERIFY = 'MICRO_ELASTIC_%s_SSL_VERIFY'; |
|
25
|
|
|
public const CFG_CLIENT_SSL_KEY = 'MICRO_ELASTIC_%s_SSL_KEY'; |
|
26
|
|
|
public const CFG_CLIENT_SSL_KEY_PWD = 'MICRO_ELASTIC_%s_SSL_KEY_PASSWORD'; |
|
27
|
|
|
public const CFG_CLIENT_API_KEY = 'MICRO_ELASTIC_%s_API_KEY'; |
|
28
|
|
|
public const CFG_CLIENT_BA_LOGIN = 'MICRO_ELASTIC_%s_AUTH_BASIC_LOGIN'; |
|
29
|
|
|
public const CFG_CLIENT_BA_PWD = 'MICRO_ELASTIC_%s_AUTH_BASIC_PASSWORD'; |
|
30
|
|
|
public const CFG_CLIENT_CLOUD_ID = 'MICRO_ELASTIC_%s_CLOUD_ID'; |
|
31
|
|
|
public const CFG_CLIENT_CA_BUNDLE = 'MICRO_ELASTIC_%s_CA_BUNDLE'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
3 |
|
public function getHosts(): array |
|
37
|
|
|
{ |
|
38
|
3 |
|
$hosts = $this->get(self::CFG_CLIENT_HOSTS, 'localhost:9200', false); |
|
39
|
|
|
|
|
40
|
3 |
|
return $this->explodeStringToArray($hosts); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritDoc} |
|
45
|
|
|
*/ |
|
46
|
3 |
|
public function getLoggerName(): string |
|
47
|
|
|
{ |
|
48
|
3 |
|
return $this->get(self::CFG_CLIENT_LOGGER, LoggerFacadeInterface::LOGGER_DEFAULT, false); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritDoc} |
|
53
|
|
|
*/ |
|
54
|
3 |
|
public function getRetries(): int |
|
55
|
|
|
{ |
|
56
|
3 |
|
return (int) $this->get(self::CFG_CLIENT_RETRIES, 1, false); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritDoc} |
|
61
|
|
|
*/ |
|
62
|
3 |
|
public function getSslVerification(): bool |
|
63
|
|
|
{ |
|
64
|
3 |
|
return (bool) $this->get(self::CFG_CLIENT_SSL_VERIFY, true, false); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* {@inheritDoc} |
|
69
|
|
|
*/ |
|
70
|
3 |
|
public function getSslKey(): string|null |
|
71
|
|
|
{ |
|
72
|
3 |
|
return $this->get(self::CFG_CLIENT_SSL_KEY); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritDoc} |
|
77
|
|
|
*/ |
|
78
|
3 |
|
public function getSslKeyPassword(): string|null |
|
79
|
|
|
{ |
|
80
|
3 |
|
return $this->get(self::CFG_CLIENT_SSL_KEY_PWD); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritDoc} |
|
85
|
|
|
*/ |
|
86
|
3 |
|
public function getApiKey(): string|null |
|
87
|
|
|
{ |
|
88
|
3 |
|
return $this->get(self::CFG_CLIENT_API_KEY); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* {@inheritDoc} |
|
93
|
|
|
*/ |
|
94
|
3 |
|
public function getBasicAuthLogin(): string |
|
95
|
|
|
{ |
|
96
|
3 |
|
return (string) $this->get(self::CFG_CLIENT_BA_LOGIN); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* {@inheritDoc} |
|
101
|
|
|
*/ |
|
102
|
3 |
|
public function getBasicAuthPassword(): string |
|
103
|
|
|
{ |
|
104
|
3 |
|
return (string) $this->get(self::CFG_CLIENT_BA_PWD); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* {@inheritDoc} |
|
109
|
|
|
*/ |
|
110
|
3 |
|
public function getElasticCloudId(): string|null |
|
111
|
|
|
{ |
|
112
|
3 |
|
return $this->get(self::CFG_CLIENT_CLOUD_ID); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* {@inheritDoc} |
|
117
|
|
|
*/ |
|
118
|
3 |
|
public function getCABundle(): string|null |
|
119
|
|
|
{ |
|
120
|
3 |
|
return $this->get(self::CFG_CLIENT_CA_BUNDLE); |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|