Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import com.dt.gatepilot.domain.enums.ConfigApplyState;
import com.dt.gatepilot.domain.resource.meta.ResourceMetadataConstants;
Expand All @@ -25,7 +25,7 @@
* agent 上报配置应用结果请求。
*/
@Data
public class ReportAgentApplyResultCommand {
public class AgentApplyResultReportRequest {

/**
* 节点命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import com.dt.gatepilot.domain.resource.meta.ResourceMetadataConstants;
import jakarta.validation.constraints.NotBlank;
Expand All @@ -25,7 +25,7 @@
* agent 拉取已发布配置请求。
*/
@Data
public class PullAgentConfigCommand {
public class AgentConfigPullRequest {

/**
* 节点命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* agent 拉取已发布配置响应。
*/
@Data
public class AgentConfigPullResult {
public class AgentConfigPullResponse {

/**
* 是否存在新配置。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import com.dt.gatepilot.domain.enums.ConfigApplyState;
import com.dt.gatepilot.domain.enums.NodePhase;
Expand All @@ -30,7 +30,7 @@
* agent 心跳请求。
*/
@Data
public class AgentHeartbeatCommand {
public class AgentHeartbeatRequest {

/**
* 节点命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* 配置版本 diff 响应。
*/
@Data
public class ConfigDiffResult {
public class ConfigDiffResponse {

/**
* 命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import com.dt.gatepilot.domain.resource.meta.LabelSelector;
import com.dt.gatepilot.domain.resource.meta.ResourceReference;
Expand All @@ -26,7 +26,7 @@
* 控制面发布请求。
*/
@Data
public class CreateReleaseCommand {
public class CreateReleaseRequest {

/**
* 命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import jakarta.validation.constraints.NotBlank;
import lombok.Data;
Expand All @@ -22,7 +22,7 @@
* 控制面回滚请求。
*/
@Data
public class CreateRollbackCommand {
public class CreateRollbackRequest {

/**
* 命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ public class ProjectTemplateDryRunResponse {
/**
* 校验消息
*/
private List<ReleaseDryRunResult.DryRunMessage> messages = new ArrayList<>();
private List<ReleaseDryRunResponse.DryRunMessage> messages = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.dt.gatepilot.apiserver.application.dto;

import com.dt.gatepilot.apiserver.application.command.CreateReleaseCommand;
import com.dt.gatepilot.apiserver.application.dto.CreateReleaseRequest;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
Expand Down Expand Up @@ -49,7 +49,7 @@ public class ProjectTemplatePreviewResponse {
/**
* 发布请求预览
*/
private CreateReleaseCommand releaseRequest;
private CreateReleaseRequest releaseRequest;

/**
* 资源差异摘要
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import com.dt.gatepilot.domain.enums.NodeRole;
import com.dt.gatepilot.domain.resource.meta.LabelSelector;
Expand All @@ -29,7 +29,7 @@
* agent 节点注册请求。
*/
@Data
public class RegisterAgentCommand {
public class RegisterAgentRequest {

/**
* 节点命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* 发布 dry-run 校验响应。
*/
@Data
public class ReleaseDryRunResult {
public class ReleaseDryRunResponse {

/**
* 命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* 发布请求响应。
*/
@Data
public class ReleaseResult {
public class ReleaseResponse {

/**
* 发布请求标识。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dt.gatepilot.apiserver.application.command;
package com.dt.gatepilot.apiserver.application.dto;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
Expand All @@ -23,10 +23,10 @@
import lombok.Data;

/**
* agent 上报运行审计命令
* agent 上报运行审计请求
*/
@Data
public class ReportRuntimeAuditCommand {
public class RuntimeAuditReportRequest {

/**
* 命名空间。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import lombok.Data;

/**
* 运行审计上报结果
* 运行审计上报响应
*/
@Data
public class RuntimeAuditReportResult {
public class RuntimeAuditReportResponse {

/**
* 接收条数。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
*/
package com.dt.gatepilot.apiserver.application.service;

import com.dt.gatepilot.apiserver.application.dto.AgentApplyResultReportRequest;
import com.dt.gatepilot.apiserver.application.dto.AgentConfigPullRequest;
import com.dt.gatepilot.apiserver.application.dto.AgentConfigPullResponse;
import com.dt.gatepilot.apiserver.application.dto.AgentHeartbeatRequest;
import com.dt.gatepilot.apiserver.application.dto.RegisterAgentRequest;
import com.dt.gatepilot.apiserver.domain.model.CursorPage;
import com.dt.gatepilot.apiserver.domain.resource.GatePilotResourcePaths;
import com.dt.gatepilot.apiserver.domain.resource.GatePilotResourceType;
import com.dt.gatepilot.apiserver.infrastructure.config.ConditionalOnGatePilotApiserverEnabled;
import com.dt.gatepilot.domain.enums.ConfigApplyState;
import com.dt.gatepilot.domain.enums.NodePhase;
import com.dt.gatepilot.domain.enums.ResourceKind;
import com.dt.gatepilot.domain.resource.meta.ResourceMetadataConstants;
import com.dt.gatepilot.domain.resource.node.GatewayNode;
import com.dt.gatepilot.domain.resource.node.GatewayNodeStatus;
import com.dt.gatepilot.domain.resource.publish.PublishedConfig;
import com.dt.gatepilot.apiserver.application.command.ReportAgentApplyResultCommand;
import com.dt.gatepilot.apiserver.application.command.PullAgentConfigCommand;
import com.dt.gatepilot.apiserver.application.command.AgentHeartbeatCommand;
import com.dt.gatepilot.apiserver.application.command.RegisterAgentCommand;
import com.dt.gatepilot.apiserver.application.dto.AgentConfigPullResult;
import com.dt.gatepilot.apiserver.domain.model.CursorPage;
import com.dt.gatepilot.apiserver.domain.resource.GatePilotResourcePaths;
import com.dt.gatepilot.apiserver.domain.resource.GatePilotResourceType;
import com.dt.gatepilot.apiserver.infrastructure.config.ConditionalOnGatePilotApiserverEnabled;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Comparator;
Expand Down Expand Up @@ -63,7 +63,7 @@ public GatePilotAgentService(GatePilotResourceService resourceService) {
* @param request 注册请求
* @return 节点资源
*/
public GatewayNode register(RegisterAgentCommand request) {
public GatewayNode register(RegisterAgentRequest request) {
GatewayNode node = new GatewayNode();
// 节点资源名和 nodeId 保持一致,便于控制台排查
node.getMetadata().setName(request.getNodeId());
Expand Down Expand Up @@ -92,7 +92,7 @@ public GatewayNode register(RegisterAgentCommand request) {
* @param request 心跳请求
* @return 节点资源
*/
public GatewayNode heartbeat(AgentHeartbeatCommand request) {
public GatewayNode heartbeat(AgentHeartbeatRequest request) {
GatewayNode node = loadOrCreateNode(request.getNamespace(), request.getNodeId());
GatewayNodeStatus status = node.getStatus();
// 心跳以最新快照覆盖节点状态
Expand Down Expand Up @@ -123,15 +123,15 @@ public GatewayNode heartbeat(AgentHeartbeatCommand request) {
* @param request 拉取请求
* @return 拉取响应
*/
public AgentConfigPullResult pullConfig(PullAgentConfigCommand request) {
public AgentConfigPullResponse pullConfig(AgentConfigPullRequest request) {
PublishedConfig latest = listPublishedConfigs(request.getNamespace())
.stream()
.filter(config -> request.getConfigShards().isEmpty()
|| request.getConfigShards().contains(config.getSpec().getConfigShard()))
.filter(config -> isolationGroupMatches(config, request))
.max(Comparator.comparing(config -> Objects.requireNonNullElse(config.getSpec().getSequence(), 0L)))
.orElse(null);
AgentConfigPullResult response = new AgentConfigPullResult();
AgentConfigPullResponse response = new AgentConfigPullResponse();
if (latest == null) {
// 没有目标配置时让 agent 保持当前 last-good
response.setChanged(false);
Expand All @@ -155,7 +155,7 @@ public AgentConfigPullResult pullConfig(PullAgentConfigCommand request) {
* @param request 上报请求
* @return 节点资源
*/
public GatewayNode reportApplyResult(ReportAgentApplyResultCommand request) {
public GatewayNode reportApplyResult(AgentApplyResultReportRequest request) {
GatewayNode node = loadOrCreateNode(request.getNamespace(), request.getNodeId());
GatewayNodeStatus status = node.getStatus();
// agent 上报的 apply 结果是节点状态的事实来源
Expand Down Expand Up @@ -194,7 +194,7 @@ private List<PublishedConfig> listPublishedConfigs(String namespace) {
return configs;
}

private boolean isolationGroupMatches(PublishedConfig config, PullAgentConfigCommand request) {
private boolean isolationGroupMatches(PublishedConfig config, AgentConfigPullRequest request) {
String targetIsolationGroup = config.getSpec().getIsolationGroup();
return !StringUtils.hasText(targetIsolationGroup)
|| Objects.equals(targetIsolationGroup, request.getIsolationGroup());
Expand All @@ -205,7 +205,7 @@ private GatewayNode loadOrCreateNode(String namespace, String nodeId) {
return (GatewayNode) resourceService.get(GatePilotResourcePaths.NODES, namespace, nodeId);
} catch (RuntimeException exception) {
// 心跳先到时自动补节点,避免部署顺序影响状态上报
RegisterAgentCommand request = new RegisterAgentCommand();
RegisterAgentRequest request = new RegisterAgentRequest();
request.setNamespace(namespace);
request.setNodeId(nodeId);
return register(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.dt.gatepilot.domain.resource.config.GatewayConfigSnapshot;
import com.dt.gatepilot.domain.resource.publish.PublishedConfig;
import com.dt.gatepilot.apiserver.application.dto.ConfigSnapshotSummaryResponse;
import com.dt.gatepilot.apiserver.application.dto.ConfigDiffResult;
import com.dt.gatepilot.apiserver.application.dto.ConfigDiffResponse;
import com.dt.gatepilot.apiserver.domain.model.CursorPage;
import com.dt.gatepilot.apiserver.domain.repository.ResourceStoreConstants;
import com.dt.gatepilot.apiserver.domain.resource.GatePilotResourcePaths;
Expand Down Expand Up @@ -207,14 +207,14 @@ public Optional<GatewayConfigSnapshot> findSnapshot(String namespace, String ver
* @param configShard 配置分片
* @return diff 响应
*/
public ConfigDiffResult diff(String namespace, String baseVersion, String targetVersion, String configShard) {
public ConfigDiffResponse diff(String namespace, String baseVersion, String targetVersion, String configShard) {
GatewayConfigSnapshot base = findSnapshot(namespace, baseVersion, configShard)
.orElseThrow(() -> notFound("基线配置快照不存在: " + baseVersion));
GatewayConfigSnapshot target = findSnapshot(namespace, targetVersion, configShard)
.orElseThrow(() -> notFound("目标配置快照不存在: " + targetVersion));
PublishedConfig baseConfig = base.getSpec().getPublishedConfig();
PublishedConfig targetConfig = target.getSpec().getPublishedConfig();
ConfigDiffResult response = new ConfigDiffResult();
ConfigDiffResponse response = new ConfigDiffResponse();
// diff 只比较快照中的 PublishedConfig 内容
response.setNamespace(namespace);
response.setBaseVersion(baseVersion);
Expand Down Expand Up @@ -248,7 +248,7 @@ public ConfigDiffResult diff(String namespace, String baseVersion, String target
return response;
}

private <T> DiffStats appendDiffItems(ConfigDiffResult response,
private <T> DiffStats appendDiffItems(ConfigDiffResponse response,
String resourceType,
List<T> baseItems,
List<T> targetItems,
Expand Down Expand Up @@ -296,12 +296,12 @@ private <T> Map<String, T> indexByKey(List<T> items, Function<T, String> keyMapp
return index;
}

private ConfigDiffResult.ConfigDiffItem diffItem(String resourceType,
private ConfigDiffResponse.ConfigDiffItem diffItem(String resourceType,
String name,
String changeType,
String baseHash,
String targetHash) {
ConfigDiffResult.ConfigDiffItem item = new ConfigDiffResult.ConfigDiffItem();
ConfigDiffResponse.ConfigDiffItem item = new ConfigDiffResponse.ConfigDiffItem();
// diff item 只保留摘要,详情后续按需再查询快照
item.setResourceType(resourceType);
item.setName(name);
Expand Down
Loading
Loading