优化
This commit is contained in:
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* 跨服务和跨区域传输使用的不可变事件信封。
|
||||
* 统一测试环境中跨业务服务传输使用的不可变事件信封。
|
||||
*
|
||||
* <p>租户 ID 和聚合 ID 使用字符串,避免跨语言传输时发生大整数精度丢失。
|
||||
* {@code payloadHash} 是原始规范化负载字节的 SHA-256 摘要。</p>
|
||||
@@ -14,8 +14,6 @@ import java.time.Instant;
|
||||
* @param eventType 事件类型,不包含版本号
|
||||
* @param eventVersion 事件契约版本,从 1 开始
|
||||
* @param occurredAt 业务事实实际发生时间,使用 UTC 时间点
|
||||
* @param sourceRegion 事件来源业务单元
|
||||
* @param targetRegion 事件目标业务单元;国内一期允许与来源区域相同
|
||||
* @param tenantId 事件所属客户租户 ID
|
||||
* @param aggregateType 聚合类型
|
||||
* @param aggregateId 聚合 ID
|
||||
@@ -32,8 +30,6 @@ public record EventEnvelope(
|
||||
String eventType,
|
||||
int eventVersion,
|
||||
Instant occurredAt,
|
||||
RegionCode sourceRegion,
|
||||
RegionCode targetRegion,
|
||||
String tenantId,
|
||||
String aggregateType,
|
||||
String aggregateId,
|
||||
|
||||
-6
@@ -37,12 +37,6 @@ public final class EventEnvelopeValidator {
|
||||
if (envelope.occurredAt() == null) {
|
||||
errors.add("occurredAt 不能为空");
|
||||
}
|
||||
if (envelope.sourceRegion() == null) {
|
||||
errors.add("sourceRegion 不能为空");
|
||||
}
|
||||
if (envelope.targetRegion() == null) {
|
||||
errors.add("targetRegion 不能为空");
|
||||
}
|
||||
requireText(errors, "tenantId", envelope.tenantId(), MAX_ID_LENGTH);
|
||||
if (envelope.aggregateType() == null
|
||||
|| !AGGREGATE_TYPE_PATTERN.matcher(envelope.aggregateType()).matches()) {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.baiyue.common.event;
|
||||
|
||||
/**
|
||||
* 事件来源与目标部署区域。
|
||||
*
|
||||
* <p>区域表示独立业务单元,不表示用户当前所在地。</p>
|
||||
*/
|
||||
public enum RegionCode {
|
||||
/** 国内业务单元。 */
|
||||
CN,
|
||||
/** 海外业务单元。 */
|
||||
OVERSEAS
|
||||
}
|
||||
Reference in New Issue
Block a user