Pil0tXia commented on code in PR #52: URL: https://github.com/apache/eventmesh-dashboard/pull/52#discussion_r1516759825
########## eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java: ########## @@ -0,0 +1,80 @@ +/* + * 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.eventmesh.dashboard.console.service.config.Impl; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; +import org.apache.eventmesh.dashboard.console.service.config.ConfigService; + +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.yaml.snakeyaml.Yaml; + +@Service +public class ConfigServiceImpl implements ConfigService { + + + @Autowired + ConfigMapper configMapper; + + @Override + public String mapToYaml(Map<String, String> stringMap) { + Yaml yaml = new Yaml(); + return yaml.dumpAsMap(stringMap); + } + + @Override + public String mapToProperties(Map<String, String> stringMap) { + Properties properties = new Properties(); + stringMap.forEach((key, value) -> { + properties.setProperty(key, value); + }); + return properties.toString().replace(",", ",\n"); + } + + @Override + public Integer addConfig(ConfigEntity configEntity) { + return configMapper.addConfig(configEntity); + } + + @Override + public Integer deleteConfig(ConfigEntity configEntity) { + return configMapper.deleteConfig(configEntity); + } + + @Override + public List<ConfigEntity> selectByInstanceId(ConfigEntity configEntity) { + return configMapper.selectByInstanceId(configEntity); + } + + @Override + public List<ConfigEntity> selectDefaultConfig(ConfigEntity configEntity) { + return configMapper.selectDefaultConfig(configEntity); + } + + @Override + public void updateConfig(ConfigEntity configEntity) { + configMapper.updateConfig(configEntity); + } Review Comment: When configuration is edited, the new configs should be applied to a new service instance. However, if the new service instance failed to startup, then users will lose their old configs. Add a new config record and mark the old config record as `deleted` will be easier to collect config logs. What do you think? -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
