feat: 1.4.0
1. 优化版本获取方式
This commit is contained in:
parent
3b9f62a8e2
commit
357869aac9
@ -1,6 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.init;
|
||||
|
||||
import com.aizuda.easy.retry.client.core.Lifecycle;
|
||||
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@ -26,8 +27,8 @@ public class EasyRetryEndListener implements ApplicationListener<ContextClosedEv
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextClosedEvent event) {
|
||||
log.info("Easy-Retry client about to shutdown");
|
||||
log.info("Easy-Retry client about to shutdown v{}", EasyRetryVersion.getVersion());
|
||||
lifecycleList.forEach(Lifecycle::close);
|
||||
log.info("Easy-Retry client closed successfully");
|
||||
log.info("Easy-Retry client closed successfully v{}", EasyRetryVersion.getVersion());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.init;
|
||||
|
||||
import com.aizuda.easy.retry.client.core.Lifecycle;
|
||||
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
@ -24,8 +25,8 @@ public class EasyRetryStartListener implements ApplicationRunner {
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("Easy-Retry client is preparing to start");
|
||||
log.info("Easy-Retry client is preparing to start... v{}", EasyRetryVersion.getVersion());
|
||||
lifecycleList.forEach(Lifecycle::start);
|
||||
log.info("Easy-Retry client started successfully");
|
||||
log.info("Easy-Retry client started successfully v{}", EasyRetryVersion.getVersion());
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package com.aizuda.easy.retry.common.core.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @date : 2021-11-26 18:01
|
||||
*/
|
||||
@Getter
|
||||
public enum NotifyTypeEnum {
|
||||
|
||||
/**
|
||||
* 钉钉通知
|
||||
*/
|
||||
DING_DING(1),
|
||||
|
||||
/**
|
||||
* 邮箱通知
|
||||
*/
|
||||
EMAIL(2),
|
||||
|
||||
/**
|
||||
* 企业微信
|
||||
*/
|
||||
QI_YE_WECHAT(3),
|
||||
;
|
||||
|
||||
private final Integer type;
|
||||
|
||||
NotifyTypeEnum(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.aizuda.easy.retry.common.core.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.CodeSource;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
/**
|
||||
* 获取系统版本
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @date : 2023-05-22 08:55
|
||||
*/
|
||||
public final class EasyRetryVersion {
|
||||
|
||||
private EasyRetryVersion() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Easy Retry 最新版本号
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return determineSpringBootVersion();
|
||||
}
|
||||
|
||||
private static String determineSpringBootVersion() {
|
||||
String implementationVersion = EasyRetryVersion.class.getPackage().getImplementationVersion();
|
||||
if (implementationVersion != null) {
|
||||
return implementationVersion;
|
||||
}
|
||||
CodeSource codeSource = EasyRetryVersion.class.getProtectionDomain().getCodeSource();
|
||||
if (codeSource == null) {
|
||||
return null;
|
||||
}
|
||||
URL codeSourceLocation = codeSource.getLocation();
|
||||
try {
|
||||
URLConnection connection = codeSourceLocation.openConnection();
|
||||
if (connection instanceof JarURLConnection) {
|
||||
return getImplementationVersion(((JarURLConnection) connection).getJarFile());
|
||||
}
|
||||
try (JarFile jarFile = new JarFile(new File(codeSourceLocation.toURI()))) {
|
||||
return getImplementationVersion(jarFile);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getImplementationVersion(JarFile jarFile) throws IOException {
|
||||
return jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.model.dto;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.enums.AlarmTypeEnum;
|
||||
import com.aizuda.easy.retry.common.core.enums.NotifySceneEnum;
|
||||
import com.aizuda.easy.retry.common.core.enums.NotifyTypeEnum;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -43,7 +43,7 @@ public class ConfigDTO {
|
||||
public static class Notify {
|
||||
|
||||
/**
|
||||
* 通知类型 {@link NotifyTypeEnum}
|
||||
* 通知类型 {@link AlarmTypeEnum}
|
||||
*/
|
||||
private Integer notifyType;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.support.listener;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
|
||||
import com.aizuda.easy.retry.server.support.Lifecycle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -24,13 +25,10 @@ public class StartListener implements ApplicationListener<ContextRefreshedEvent>
|
||||
@Autowired
|
||||
private List<Lifecycle> lifecycleList;
|
||||
|
||||
@Value("${version}")
|
||||
private String version;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
LogUtils.info(log, "easy-retry-server v{} starting...", version);
|
||||
LogUtils.info(log, "easy-retry-server v{} starting...", EasyRetryVersion.getVersion());
|
||||
lifecycleList.forEach(Lifecycle::start);
|
||||
LogUtils.info(log, "easy-retry-server v{} start completed", version);
|
||||
LogUtils.info(log, "easy-retry-server v{} start completed", EasyRetryVersion.getVersion());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.web.controller;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.model.Result;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -17,11 +17,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/system")
|
||||
public class SystemInfoController {
|
||||
|
||||
@Value("${version:}")
|
||||
private String version;
|
||||
|
||||
@GetMapping("version")
|
||||
public Result<String> version() {
|
||||
return new Result<>(version);
|
||||
return new Result<>(EasyRetryVersion.getVersion());
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ mybatis-plus:
|
||||
logging:
|
||||
config: classpath:logback-boot.xml
|
||||
|
||||
version: @project.version@ #系统版本号
|
||||
|
||||
easy-retry:
|
||||
last-days: 30 # 拉取重试数据的天数
|
||||
retry-pull-page-size: 100 # 拉取重试数据的每批次的大小
|
||||
|
Loading…
Reference in New Issue
Block a user