From 3425f00bd6536362c3b9a95af0a955e6a78976e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=B9=E5=92=8C=E5=A5=B9=E7=9A=84=E7=8C=AB?= Date: Thu, 31 Aug 2023 14:12:54 +0800 Subject: [PATCH] Fixed bug that configuration of other processes were not updated when using `nacos grpc client` (#6110) --- CHANGELOG-3.0.md | 1 + src/config-nacos/src/NacosDriver.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG-3.0.md b/CHANGELOG-3.0.md index 64aa9e988b..7f49550ba9 100644 --- a/CHANGELOG-3.0.md +++ b/CHANGELOG-3.0.md @@ -4,6 +4,7 @@ - [#6097](https://github.com/hyperf/hyperf/pull/6097) Fixed error that using non-zipkin driver of tracer. - [#6099](https://github.com/hyperf/hyperf/pull/6099) Fixed bug that `ConstantFrequency` cannot work when using `redis`. +- [#6110](https://github.com/hyperf/hyperf/pull/6110) Fixed bug that configuration of other processes were not updated when using `nacos grpc client`. ## Added diff --git a/src/config-nacos/src/NacosDriver.php b/src/config-nacos/src/NacosDriver.php index ef3dab0e62..dc43931d1c 100644 --- a/src/config-nacos/src/NacosDriver.php +++ b/src/config-nacos/src/NacosDriver.php @@ -50,9 +50,15 @@ public function createMessageFetcherLoop(): void $client = $application->grpc->get($tenant); $client->listenConfig($group, $dataId, new ConfigChangeNotifyRequestHandler(function (ConfigQueryResponse $response) use ($key, $type) { - $this->updateConfig([ - $key => $this->client->decode($response->getContent(), $type), - ]); + $config = $this->client->decode($response->getContent(), $type); + $prevConfig = $this->config->get($key, []); + + if ($config !== $prevConfig) { + $this->syncConfig( + [$key => $config], + [$key => $prevConfig], + ); + } })); }