[ Service ] [ Executor ] 初步重构Executor部分的代码
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package io.wdd.func.script.service;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface FuncService {
|
||||
|
||||
List<String> callBaseFuncService(String agentTopicName, String baseFunctionName, List<String> funcArgs);
|
||||
|
||||
|
||||
List<String> callAppFuncService(String agentTopicName, String appFunctionName, List<String> funcArgs);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package io.wdd.func.script.service;
|
||||
|
||||
import io.wdd.rpc.execute.ExecutionMessageType;
|
||||
import io.wdd.rpc.execute.ExecutionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FuncServiceImpl implements FuncService {
|
||||
|
||||
@Resource
|
||||
ExecutionService executionService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> callBaseFuncService(String agentTopicName, String baseFunctionName, List<String> funcArgs) {
|
||||
|
||||
return this.syncCallFunction(
|
||||
agentTopicName,
|
||||
ExecutionMessageType.BASE,
|
||||
baseFunctionName,
|
||||
funcArgs
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> callAppFuncService(String agentTopicName, String appFunctionName, List<String> funcArgs) {
|
||||
|
||||
return this.syncCallFunction(
|
||||
agentTopicName,
|
||||
ExecutionMessageType.APP,
|
||||
appFunctionName,
|
||||
funcArgs
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private List<String> syncCallFunction(String agentTopicName, ExecutionMessageType emType, String funcName, List<String> funcArgs) {
|
||||
|
||||
// 重新构造内容
|
||||
funcArgs.add(
|
||||
0,
|
||||
funcName
|
||||
);
|
||||
|
||||
// 调用
|
||||
ArrayList<String> resultLog = executionService.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
emType.toString(),
|
||||
funcArgs,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
"",
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
return resultLog;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package io.wdd.func.xray.service;
|
||||
import io.wdd.common.utils.TimeUtils;
|
||||
import io.wdd.func.oss.config.OctopusObjectSummary;
|
||||
import io.wdd.func.xray.beans.node.ProxyNode;
|
||||
import io.wdd.rpc.execute.service.SyncExecutionService;
|
||||
import io.wdd.rpc.execute.ExecutionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -83,7 +83,7 @@ public class XrayCallAgent {
|
||||
}
|
||||
|
||||
@Resource
|
||||
SyncExecutionService executionService;
|
||||
ExecutionService executionService;
|
||||
|
||||
/**
|
||||
* 为代理链的每一个节点 构建Xray配置更新命令,然后发送至对应的Agent中
|
||||
@@ -131,17 +131,18 @@ public class XrayCallAgent {
|
||||
);
|
||||
|
||||
// 向Agent发送命令,执行更新操作!
|
||||
String resultKey = executionService.SyncSendCommandToAgent(
|
||||
executionService.SendCommandToAgent(
|
||||
proxyNode.getAgentTopicName(),
|
||||
updateCommandType,
|
||||
null,
|
||||
null,
|
||||
updateXrayCommandList,
|
||||
false,
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
return resultKey;
|
||||
return "";
|
||||
}
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Reference in New Issue
Block a user