mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Optimized code for config-nacos
. (#6903)
This commit is contained in:
parent
298230f95a
commit
e285377e67
@ -4,6 +4,10 @@
|
||||
|
||||
- [#6900](https://github.com/hyperf/hyperf/pull/6900) Fixed bug that `LengthAwarePaginator::addQuery()` cannot support array `$values`.
|
||||
|
||||
## Optimized
|
||||
|
||||
- [#6903](https://github.com/hyperf/hyperf/pull/6903) Optimized code for `config-nacos`.
|
||||
|
||||
# v3.1.27 - 2024-06-20
|
||||
|
||||
## Added
|
||||
|
@ -48,8 +48,8 @@ class Client implements ClientInterface
|
||||
|
||||
$config = [];
|
||||
foreach ($listener as $key => $item) {
|
||||
$dataId = $item['data_id'];
|
||||
$group = $item['group'];
|
||||
$dataId = $item['data_id'] ?? '';
|
||||
$group = $item['group'] ?? '';
|
||||
$tenant = $item['tenant'] ?? null;
|
||||
$type = $item['type'] ?? null;
|
||||
$response = $this->client->config->get($dataId, $group, $tenant);
|
||||
@ -66,17 +66,13 @@ class Client implements ClientInterface
|
||||
public function decode(string $body, ?string $type = null): array|string
|
||||
{
|
||||
$type = strtolower((string) $type);
|
||||
switch ($type) {
|
||||
case 'json':
|
||||
return Json::decode($body);
|
||||
case 'yml':
|
||||
case 'yaml':
|
||||
return yaml_parse($body);
|
||||
case 'xml':
|
||||
return Xml::toArray($body);
|
||||
default:
|
||||
return $body;
|
||||
}
|
||||
|
||||
return match ($type) {
|
||||
'json' => Json::decode($body),
|
||||
'yml', 'yaml' => yaml_parse($body),
|
||||
'xml' => Xml::toArray($body),
|
||||
default => $body,
|
||||
};
|
||||
}
|
||||
|
||||
public function getValidNodes(
|
||||
|
@ -45,8 +45,8 @@ class NacosDriver extends AbstractDriver
|
||||
$application = $this->client->getClient();
|
||||
$listeners = $this->config->get('config_center.drivers.nacos.listener_config', []);
|
||||
foreach ($listeners as $key => $item) {
|
||||
$dataId = $item['data_id'];
|
||||
$group = $item['group'];
|
||||
$dataId = $item['data_id'] ?? '';
|
||||
$group = $item['group'] ?? '';
|
||||
$tenant = $item['tenant'] ?? '';
|
||||
$type = $item['type'] ?? null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user