Patrick0308 commented on a change in pull request #1161:
URL: https://github.com/apache/dubbo-go/pull/1161#discussion_r615399022



##########
File path: registry/event/base_configuration_listener.go
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package event
+
+import (
+       perrors "github.com/pkg/errors"
+)
+
+import (
+       "github.com/apache/dubbo-go/common"
+       "github.com/apache/dubbo-go/common/config"
+       "github.com/apache/dubbo-go/common/constant"
+       "github.com/apache/dubbo-go/common/logger"
+       "github.com/apache/dubbo-go/config_center"
+       "github.com/apache/dubbo-go/remoting"
+)
+
+// nolint
+type BaseConfigurationListener struct {
+       configurators           []config_center.Configurator
+       dynamicConfiguration    config_center.DynamicConfiguration
+       defaultConfiguratorFunc func(url *common.URL) config_center.Configurator
+}
+
+// Configurators gets Configurator from config center
+func (bcl *BaseConfigurationListener) Configurators() 
[]config_center.Configurator {
+       return bcl.configurators
+}
+
+// InitWith will init BaseConfigurationListener by @key+@Listener+@f
+func (bcl *BaseConfigurationListener) InitWith(key string, listener 
config_center.ConfigurationListener,
+       f func(url *common.URL) config_center.Configurator) {
+
+       bcl.dynamicConfiguration = 
config.GetEnvInstance().GetDynamicConfiguration()
+       if bcl.dynamicConfiguration == nil {
+               // set configurators to empty
+               bcl.configurators = []config_center.Configurator{}
+               return
+       }
+       bcl.defaultConfiguratorFunc = f
+       bcl.dynamicConfiguration.AddListener(key, listener)
+       if rawConfig, err := bcl.dynamicConfiguration.GetInternalProperty(key,
+               config_center.WithGroup(constant.DUBBO)); err != nil {
+               // set configurators to empty
+               bcl.configurators = []config_center.Configurator{}
+               return
+       } else if len(rawConfig) > 0 {
+               if err := bcl.genConfiguratorFromRawRule(rawConfig); err != nil 
{
+                       
logger.Error("bcl.genConfiguratorFromRawRule(rawConfig:%v) = error:%v", 
rawConfig, err)
+               }
+       }
+}
+
+// Process the notification event once there's any change happens on the 
config.
+func (bcl *BaseConfigurationListener) Process(event 
*config_center.ConfigChangeEvent) {
+       logger.Infof("Notification of overriding rule, change type is: %v , raw 
config content is:%v", event.ConfigType, event.Value)

Review comment:
       I change Infof to Debugf




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to