feat: 1.4.0
1. 支持初始化场景配置
This commit is contained in:
parent
9333288e7e
commit
1d0e792eb0
@ -8,6 +8,7 @@ CREATE TABLE `group_config`
|
|||||||
`group_partition` int(11) NOT NULL COMMENT '分区',
|
`group_partition` int(11) NOT NULL COMMENT '分区',
|
||||||
`route_key` tinyint(4) NOT NULL COMMENT '路由策略',
|
`route_key` tinyint(4) NOT NULL COMMENT '路由策略',
|
||||||
`id_generator_mode` tinyint(4) NOT NULL DEFAULT '1' COMMENT '唯一id生成模式 默认号段模式',
|
`id_generator_mode` tinyint(4) NOT NULL DEFAULT '1' COMMENT '唯一id生成模式 默认号段模式',
|
||||||
|
`init_scene` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否初始化场景 0:否 1:是',
|
||||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
|
@ -123,5 +123,6 @@ public @interface Retryable {
|
|||||||
*/
|
*/
|
||||||
TimeUnit unit() default TimeUnit.MILLISECONDS;
|
TimeUnit unit() default TimeUnit.MILLISECONDS;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ public enum DelayLevelEnum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new EasyRetryCommonException("level:[{}] 不存在", level);
|
// 若配置的不存在默认1个小时一次
|
||||||
|
return DelayLevelEnum._15;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ public class GroupConfig implements Serializable {
|
|||||||
|
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
|
private Integer initScene;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private LocalDateTime createDt;
|
private LocalDateTime createDt;
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.aizuda.easy.retry.server.service.impl;
|
package com.aizuda.easy.retry.server.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
|
||||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||||
import com.aizuda.easy.retry.server.exception.EasyRetryServerException;
|
import com.aizuda.easy.retry.server.exception.EasyRetryServerException;
|
||||||
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
|
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.RetryDeadLetterMapper;
|
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.RetryDeadLetterMapper;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.RetryTaskMapper;
|
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.RetryTaskMapper;
|
||||||
|
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.SceneConfigMapper;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.po.GroupConfig;
|
import com.aizuda.easy.retry.server.persistence.mybatis.po.GroupConfig;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.po.RetryDeadLetter;
|
import com.aizuda.easy.retry.server.persistence.mybatis.po.RetryDeadLetter;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.po.RetryTask;
|
import com.aizuda.easy.retry.server.persistence.mybatis.po.RetryTask;
|
||||||
@ -14,6 +16,7 @@ import com.aizuda.easy.retry.server.persistence.support.ConfigAccess;
|
|||||||
import com.aizuda.easy.retry.server.persistence.support.RetryTaskAccess;
|
import com.aizuda.easy.retry.server.persistence.support.RetryTaskAccess;
|
||||||
import com.aizuda.easy.retry.server.support.generator.IdGenerator;
|
import com.aizuda.easy.retry.server.support.generator.IdGenerator;
|
||||||
import com.aizuda.easy.retry.server.support.strategy.WaitStrategies;
|
import com.aizuda.easy.retry.server.support.strategy.WaitStrategies;
|
||||||
|
import com.aizuda.easy.retry.server.support.strategy.WaitStrategies.WaitStrategyEnum;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
||||||
import com.aizuda.easy.retry.server.config.RequestDataHelper;
|
import com.aizuda.easy.retry.server.config.RequestDataHelper;
|
||||||
@ -49,18 +52,18 @@ public class RetryServiceImpl implements RetryService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("retryTaskAccessProcessor")
|
@Qualifier("retryTaskAccessProcessor")
|
||||||
private RetryTaskAccess<RetryTask> retryTaskAccess;
|
private RetryTaskAccess<RetryTask> retryTaskAccess;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("configAccessProcessor")
|
@Qualifier("configAccessProcessor")
|
||||||
private ConfigAccess configAccess;
|
private ConfigAccess configAccess;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private List<IdGenerator> idGeneratorList;
|
private List<IdGenerator> idGeneratorList;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RetryTaskMapper retryTaskMapper;
|
private RetryTaskMapper retryTaskMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RetryDeadLetterMapper retryDeadLetterMapper;
|
private RetryDeadLetterMapper retryDeadLetterMapper;
|
||||||
|
@Autowired
|
||||||
|
private SceneConfigMapper sceneConfigMapper;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@ -69,7 +72,18 @@ public class RetryServiceImpl implements RetryService {
|
|||||||
|
|
||||||
SceneConfig sceneConfig = configAccess.getSceneConfigByGroupNameAndSceneName(retryTaskDTO.getGroupName(), retryTaskDTO.getSceneName());
|
SceneConfig sceneConfig = configAccess.getSceneConfigByGroupNameAndSceneName(retryTaskDTO.getGroupName(), retryTaskDTO.getSceneName());
|
||||||
if (Objects.isNull(sceneConfig)) {
|
if (Objects.isNull(sceneConfig)) {
|
||||||
throw new EasyRetryServerException("failed to report data, no scene configuration found. groupName:[{}] sceneName:[{}]", retryTaskDTO.getGroupName(), retryTaskDTO.getSceneName());
|
|
||||||
|
GroupConfig groupConfig = configAccess.getGroupConfigByGroupName(retryTaskDTO.getGroupName());
|
||||||
|
if (Objects.isNull(groupConfig)) {
|
||||||
|
throw new EasyRetryServerException("failed to report data, no group configuration found. groupName:[{}]", retryTaskDTO.getGroupName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupConfig.getInitScene().equals(StatusEnum.NO.getStatus())) {
|
||||||
|
throw new EasyRetryServerException("failed to report data, no scene configuration found. groupName:[{}] sceneName:[{}]", retryTaskDTO.getGroupName(), retryTaskDTO.getSceneName());
|
||||||
|
} else {
|
||||||
|
// 若配置了默认初始化场景配置,则发现上报数据的时候未配置场景,默认生成一个场景
|
||||||
|
initScene(retryTaskDTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestDataHelper.setPartition(retryTaskDTO.getGroupName());
|
RequestDataHelper.setPartition(retryTaskDTO.getGroupName());
|
||||||
@ -100,6 +114,26 @@ public class RetryServiceImpl implements RetryService {
|
|||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 若配置了默认初始化场景配置,则发现上报数据的时候未配置场景,默认生成一个场景
|
||||||
|
* backOff(退避策略): 等级策略
|
||||||
|
* maxRetryCount(最大重试次数): 26
|
||||||
|
* triggerInterval(间隔时间): see: {@link com.aizuda.easy.retry.common.core.enums.DelayLevelEnum}
|
||||||
|
*
|
||||||
|
* @param retryTaskDTO 重试上报DTO
|
||||||
|
*/
|
||||||
|
private void initScene(final RetryTaskDTO retryTaskDTO) {
|
||||||
|
SceneConfig sceneConfig;
|
||||||
|
sceneConfig = new SceneConfig();
|
||||||
|
sceneConfig.setGroupName(retryTaskDTO.getGroupName());
|
||||||
|
sceneConfig.setSceneName(retryTaskDTO.getSceneName());
|
||||||
|
sceneConfig.setSceneStatus(StatusEnum.YES.getStatus());
|
||||||
|
sceneConfig.setBackOff(WaitStrategyEnum.DELAY_LEVEL.getBackOff());
|
||||||
|
sceneConfig.setMaxRetryCount(26);
|
||||||
|
sceneConfig.setDescription("注解配置开启默认初始化场景");
|
||||||
|
Assert.isTrue(1 == sceneConfigMapper.insert(sceneConfig), () -> new EasyRetryServerException("init scene error"));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public Boolean batchReportRetry(List<RetryTaskDTO> retryTaskDTOList) {
|
public Boolean batchReportRetry(List<RetryTaskDTO> retryTaskDTOList) {
|
||||||
|
@ -12,6 +12,7 @@ import com.aizuda.easy.retry.server.support.RetryContext;
|
|||||||
import com.aizuda.easy.retry.server.support.WaitStrategy;
|
import com.aizuda.easy.retry.server.support.WaitStrategy;
|
||||||
import com.aizuda.easy.retry.server.support.context.MaxAttemptsPersistenceRetryContext;
|
import com.aizuda.easy.retry.server.support.context.MaxAttemptsPersistenceRetryContext;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -34,6 +35,7 @@ public class WaitStrategies {
|
|||||||
private WaitStrategies() {
|
private WaitStrategies() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum WaitStrategyEnum {
|
public enum WaitStrategyEnum {
|
||||||
DELAY_LEVEL(1, delayLevelWait()),
|
DELAY_LEVEL(1, delayLevelWait()),
|
||||||
FIXED(2, fixedWait()),
|
FIXED(2, fixedWait()),
|
||||||
|
@ -46,6 +46,11 @@ public class GroupConfigRequestVO {
|
|||||||
*/
|
*/
|
||||||
private Integer idGeneratorMode;
|
private Integer idGeneratorMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否初始化场景
|
||||||
|
*/
|
||||||
|
private Integer initScene;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知列表
|
* 通知列表
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +30,8 @@ public class GroupConfigResponseVO {
|
|||||||
|
|
||||||
private String idGeneratorModeName;
|
private String idGeneratorModeName;
|
||||||
|
|
||||||
|
private Integer initScene;
|
||||||
|
|
||||||
private List<String> onlinePodList;
|
private List<String> onlinePodList;
|
||||||
|
|
||||||
private LocalDateTime createDt;
|
private LocalDateTime createDt;
|
||||||
|
@ -9,12 +9,13 @@
|
|||||||
<result column="group_partition" jdbcType="TINYINT" property="groupPartition" />
|
<result column="group_partition" jdbcType="TINYINT" property="groupPartition" />
|
||||||
<result column="route_key" jdbcType="TINYINT" property="routeKey" />
|
<result column="route_key" jdbcType="TINYINT" property="routeKey" />
|
||||||
<result column="id_generator_mode" jdbcType="TINYINT" property="idGeneratorMode" />
|
<result column="id_generator_mode" jdbcType="TINYINT" property="idGeneratorMode" />
|
||||||
|
<result column="init_scene" jdbcType="TINYINT" property="initScene" />
|
||||||
<result column="description" jdbcType="TINYINT" property="description" />
|
<result column="description" jdbcType="TINYINT" property="description" />
|
||||||
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
|
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
|
||||||
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
|
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, `group_name`, group_status, version, `group_partition`, route_key, id_generator_mode, description, create_dt, update_dt
|
id, `group_name`, group_status, version, `group_partition`, route_key, id_generator_mode, init_scene, description, create_dt, update_dt
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -26,5 +26,4 @@ public class RetryRegisterService {
|
|||||||
return "这是一个简单的异常方法";
|
return "这是一个简单的异常方法";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
<span slot="groupStatus" slot-scope="text">
|
<span slot="groupStatus" slot-scope="text">
|
||||||
{{ text === 0 ? '停用': '启用' }}
|
{{ text === 0 ? '停用': '启用' }}
|
||||||
</span>
|
</span>
|
||||||
|
<span slot="initScene" slot-scope="text">
|
||||||
|
{{ text === 0 ? '否': '是' }}
|
||||||
|
</span>
|
||||||
<span slot="action" slot-scope="text, record">
|
<span slot="action" slot-scope="text, record">
|
||||||
<template>
|
<template>
|
||||||
<a @click="handleEdit(record)">编辑</a>
|
<a @click="handleEdit(record)">编辑</a>
|
||||||
@ -103,10 +106,15 @@ export default {
|
|||||||
dataIndex: 'groupPartition',
|
dataIndex: 'groupPartition',
|
||||||
needTotal: true
|
needTotal: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'ID生成模式',
|
title: 'ID生成模式',
|
||||||
dataIndex: 'idGeneratorModeName'
|
dataIndex: 'idGeneratorModeName'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '初始化场景',
|
||||||
|
dataIndex: 'initScene',
|
||||||
|
scopedSlots: { customRender: 'initScene' }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '更新时间',
|
title: '更新时间',
|
||||||
dataIndex: 'updateDt',
|
dataIndex: 'updateDt',
|
||||||
|
@ -77,6 +77,19 @@
|
|||||||
label="Id生成模式">
|
label="Id生成模式">
|
||||||
<a-select
|
<a-select
|
||||||
placeholder="请选择Id生成模式"
|
placeholder="请选择Id生成模式"
|
||||||
|
v-decorator="[
|
||||||
|
'initScene',
|
||||||
|
{rules: [{ required: true, message: '请选择Id生成模式'}]}
|
||||||
|
]" >
|
||||||
|
<a-select-option :value="key" v-for="(value, key) in initScene" :key="key">{{ value }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :lg="3" :md="6" :sm="12">
|
||||||
|
<a-form-item
|
||||||
|
label="初始化场景">
|
||||||
|
<a-select
|
||||||
|
placeholder="请选择是否初始化场景"
|
||||||
v-decorator="[
|
v-decorator="[
|
||||||
'idGeneratorMode',
|
'idGeneratorMode',
|
||||||
{rules: [{ required: true, message: '请选择Id生成模式'}]}
|
{rules: [{ required: true, message: '请选择Id生成模式'}]}
|
||||||
@ -116,6 +129,10 @@ export default {
|
|||||||
idGenMode: {
|
idGenMode: {
|
||||||
'1': '号段模式',
|
'1': '号段模式',
|
||||||
'2': '雪花算法'
|
'2': '雪花算法'
|
||||||
|
},
|
||||||
|
initScene: {
|
||||||
|
'0': '否',
|
||||||
|
'1': '是'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -159,13 +176,13 @@ export default {
|
|||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
setTimeout(resolve, 1500)
|
setTimeout(resolve, 1500)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const formData = pick(data, ['id', 'groupName', 'routeKey', 'groupStatus', 'description', 'groupPartition', 'idGeneratorMode'])
|
const formData = pick(data, ['id', 'groupName', 'routeKey', 'groupStatus', 'description', 'groupPartition', 'idGeneratorMode', 'initScene'])
|
||||||
formData.groupStatus = formData.groupStatus.toString()
|
formData.groupStatus = formData.groupStatus.toString()
|
||||||
formData.routeKey = formData.routeKey.toString()
|
formData.routeKey = formData.routeKey.toString()
|
||||||
formData.idGeneratorMode = formData.idGeneratorMode.toString()
|
formData.idGeneratorMode = formData.idGeneratorMode.toString()
|
||||||
|
formData.initScene = formData.initScene.toString()
|
||||||
this.id = formData.id
|
this.id = formData.id
|
||||||
|
|
||||||
console.log('formData', formData)
|
|
||||||
form.setFieldsValue(formData)
|
form.setFieldsValue(formData)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user