77 lines
1.9 KiB
Java
77 lines
1.9 KiB
Java
package io.wdd.rpc.execute;
|
||
|
||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||
import io.wdd.common.utils.TimeUtils;
|
||
import lombok.AllArgsConstructor;
|
||
import lombok.Data;
|
||
import lombok.NoArgsConstructor;
|
||
import lombok.experimental.SuperBuilder;
|
||
|
||
import java.time.LocalDateTime;
|
||
import java.util.List;
|
||
|
||
@Data
|
||
@AllArgsConstructor
|
||
@NoArgsConstructor
|
||
@SuperBuilder(toBuilder = true)
|
||
public class ExecutionMessage {
|
||
|
||
/**
|
||
* 2023年2月22日
|
||
* 是否需要返回 命令行的处理调用结果
|
||
* 通过 MQ返回
|
||
*/
|
||
@JsonProperty(defaultValue = "false")
|
||
boolean needResultReplay;
|
||
|
||
/**
|
||
* 2023年2月22日
|
||
* 是否是长时间持续执行任务
|
||
*/
|
||
@JsonProperty(defaultValue = "false")
|
||
boolean durationTask;
|
||
|
||
/**
|
||
* 用于区分 ExecutionMessage的类型
|
||
* 直接执行预定函数,则为 Nacos配置中的 方法名称,例如 AgentUpdate AgentReboot
|
||
*/
|
||
private String type;
|
||
|
||
/**
|
||
* 只有一行的命令行
|
||
*/
|
||
private List<String> singleLineCommand;
|
||
/**
|
||
* add in 2023-1-17
|
||
* 页面定时脚本任务 需要传递完整的命令列表
|
||
*/
|
||
private List<List<String>> multiLineCommand;
|
||
|
||
/**
|
||
* 词条执行命令的返回结果在Redis中的ResultKey
|
||
*/
|
||
private String resultKey;
|
||
|
||
/**
|
||
* 生成 Command结果的 resultKey
|
||
*
|
||
* @param topicName
|
||
* @return
|
||
*/
|
||
public static String GetResultKey(String topicName) {
|
||
return topicName + "-Execution:" + TimeUtils.currentTimeStringFullSplit();
|
||
}
|
||
|
||
/**
|
||
* 延迟执行任务,执行的Key为未来的,生成这个和Key
|
||
*
|
||
* @param topicName
|
||
* @param futureExecutionTime
|
||
* @return
|
||
*/
|
||
public static String GetFutureResultKey(String topicName, LocalDateTime futureExecutionTime) {
|
||
return topicName + "-Execution:" + TimeUtils.localDateTimeString(futureExecutionTime);
|
||
}
|
||
|
||
}
|