nobodyiam commented on a change in pull request #2160: [Dubbo-2030] A basically running demo implementation for introducing dynamic configuration to Dubbo. URL: https://github.com/apache/incubator-dubbo/pull/2160#discussion_r207071852
########## File path: dubbo-config/dubbo-config-dynamic/src/main/java/org/apache/dubbo/config/dynamic/support/apollo/ApolloDynamicConfiguration.java ########## @@ -0,0 +1,134 @@ +/* + * 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 org.apache.dubbo.config.dynamic.support.apollo; + +import com.ctrip.framework.apollo.Config; +import com.ctrip.framework.apollo.ConfigChangeListener; +import com.ctrip.framework.apollo.ConfigService; +import com.ctrip.framework.apollo.enums.PropertyChangeType; +import com.ctrip.framework.apollo.model.ConfigChange; +import com.ctrip.framework.apollo.model.ConfigChangeEvent; +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.config.dynamic.AbstractDynamicConfiguration; +import org.apache.dubbo.config.dynamic.ConfigChangeType; +import org.apache.dubbo.config.dynamic.ConfigType; +import org.apache.dubbo.config.dynamic.ConfigurationListener; + +/** + * + */ +public class ApolloDynamicConfiguration extends AbstractDynamicConfiguration { + private static final String APOLLO_ENV_KEY = "env"; + // FIXME the key? + private static final String APOLLO_ADDR_KEY = ""; + private static final String APOLLO_CLUSTER_KEY = "apollo.cluster"; + /** + * support two namespaces: application -> dubbo + */ + private Config dubboConfig; + private Config appConfig; Review comment: It's a good idea to support 2 namespaces: application and dubbo. However, users might only use one namespace to store dubbo's config, which means apollo client might not load one of the 2 namespaces and will print warning messages saying `Could not load config for namespace xx...` every minute, see [DefaultConfig](https://github.com/ctripcorp/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java#L91) I'm thinking to provide a new api for this kind of scenario, to get some config _optionally_, so that it won't print any message if load failed. How do you think? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
