mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
通过http从canal-admin中拉配置 (#2093)
* modify * http拉取配置监听 * revert main pom * 整理代码
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.alibaba.otter.canal.admin.controller;
|
||||
|
||||
import com.alibaba.otter.canal.admin.model.BaseModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.alibaba.otter.canal.admin.model.BaseModel;
|
||||
import com.alibaba.otter.canal.admin.model.CanalConfig;
|
||||
import com.alibaba.otter.canal.admin.service.CanalConfigService;
|
||||
|
||||
@@ -31,6 +31,17 @@ public class CanalConfigController {
|
||||
return BaseModel.getInstance(canalConfigService.getCanalConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息摘要(无配置内容)
|
||||
*
|
||||
* @param env 环境变量
|
||||
* @return 配置信息摘要
|
||||
*/
|
||||
@GetMapping(value = "/config/summary")
|
||||
public BaseModel<CanalConfig> canalConfigSummary(@PathVariable String env) {
|
||||
return BaseModel.getInstance(canalConfigService.getCanalConfigSummary());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配置
|
||||
*
|
||||
|
||||
@@ -6,6 +6,8 @@ public interface CanalConfigService {
|
||||
|
||||
CanalConfig getCanalConfig();
|
||||
|
||||
CanalConfig getCanalConfigSummary();
|
||||
|
||||
CanalConfig getAdapterConfig();
|
||||
|
||||
void updateContent(CanalConfig canalConfig);
|
||||
|
||||
@@ -47,6 +47,15 @@ public class CanalConfigServiceImpl implements CanalConfigService {
|
||||
return config;
|
||||
}
|
||||
|
||||
public CanalConfig getCanalConfigSummary() {
|
||||
return CanalConfig.find.query()
|
||||
.setDisableLazyLoading(true)
|
||||
.select("name, modifiedTime")
|
||||
.where()
|
||||
.eq("id", 1L)
|
||||
.findOne();
|
||||
}
|
||||
|
||||
public CanalConfig getAdapterConfig() {
|
||||
long id = 2L;
|
||||
CanalConfig config = CanalConfig.find.byId(id);
|
||||
|
||||
@@ -7,8 +7,8 @@ spring:
|
||||
|
||||
spring.datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/canal_manager?useUnicode=true&characterEncoding=UTF-8&useSSL=false
|
||||
username: canal
|
||||
password: canal
|
||||
username: root
|
||||
password: 121212
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
hikari:
|
||||
maximum-pool-size: 10
|
||||
|
||||
Reference in New Issue
Block a user