Wow 编译器
Wow 编译器负责:
- 在限界上下文范围内生成聚合根及其定义的命令和领域事件的元数据。
- 生成状态聚合根的查询属性导航,防止在写查询条件时出现拼写错误。
安装
kotlin
ksp("me.ahoo.wow:wow-compiler")
groovy
ksp 'me.ahoo.wow:wow-compiler'
元数据 Schema
json
{
"$schema": "http://json-schema.org/draft-04/schema",
"$id": "https://github.com/Ahoo-Wang/Wow/blob/main/schema/wow-metadata.schema.json",
"title": "Wow Metadata Schema",
"description": "Wow Metadata Schema",
"type": "object",
"properties": {
"contexts": {
"$ref": "#/definitions/contexts"
}
},
"required": [
"contexts"
],
"additionalProperties": false,
"definitions": {
"contexts": {
"description": "Bounded Context Name Map Bounded Context",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/boundedContext"
}
},
"boundedContext": {
"description": "Bounded Context Definition",
"type": "object",
"properties": {
"alias": {
"description": "Bounded Context Alias",
"type": [
"string",
"null"
]
},
"scopes": {
"description": "Bounded Context Scope",
"type": "array",
"items": {
"type": "string"
}
},
"aggregates": {
"$ref": "#/definitions/aggregates"
}
},
"additionalProperties": false
},
"aggregates": {
"description": "Aggregate name Map Aggregate",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/aggregate"
}
},
"aggregate": {
"description": "Aggregate Root Definition",
"type": "object",
"properties": {
"type": {
"description": "Aggregate Root type fully qualified name",
"type": [
"string",
"null"
]
},
"scopes": {
"description": "Aggregate Root Scope",
"type": "array",
"items": {
"type": "string"
}
},
"tenantId": {
"description": "Aggregate Root Static Tenant Id",
"type": [
"string",
"null"
]
},
"id": {
"description": "Aggregate Root Id Generator name",
"type": [
"string",
"null"
]
},
"commands": {
"description": "Aggregate Root Commands fully qualified name",
"type": "array",
"items": {
"type": "string"
}
},
"events": {
"description": "Aggregate Root Domain Event fully qualified name",
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
}
}
}
生成事件补偿服务的元数据
json
{
"contexts": {
"compensation-service": {
"alias": null,
"scopes": [
"me.ahoo.wow.compensation.domain"
],
"aggregates": {
"execution_failed": {
"scopes": [],
"type": "me.ahoo.wow.compensation.domain.ExecutionFailed",
"tenantId": null,
"id": null,
"commands": [
"me.ahoo.wow.compensation.api.CreateExecutionFailed",
"me.ahoo.wow.compensation.api.PrepareCompensation",
"me.ahoo.wow.compensation.api.ForcePrepareCompensation",
"me.ahoo.wow.compensation.api.ApplyExecutionFailed",
"me.ahoo.wow.compensation.api.ApplyExecutionSuccess",
"me.ahoo.wow.compensation.api.ApplyRetrySpec"
],
"events": [
"me.ahoo.wow.compensation.api.ExecutionFailedCreated",
"me.ahoo.wow.compensation.api.CompensationPrepared",
"me.ahoo.wow.compensation.api.ExecutionFailedApplied",
"me.ahoo.wow.compensation.api.ExecutionSuccessApplied",
"me.ahoo.wow.compensation.api.RetrySpecApplied"
]
}
}
}
}
}
生成查询状态聚合根属性导航
kotlin
package me.ahoo.wow.compensation.domain
import javax.annotation.processing.Generated
@Generated("me.ahoo.wow.compiler.query.QuerySymbolProcessorProvider", date = "2024-04-29T22:57:44.198877")
object ExecutionFailedStateProperties {
const val EVENT_ID = "eventId"
const val EVENT_ID__AGGREGATE_ID = "eventId.aggregateId"
const val EVENT_ID__ID = "eventId.id"
const val EVENT_ID__INITIALIZED = "eventId.initialized"
const val EVENT_ID__IS_INITIAL_VERSION = "eventId.isInitialVersion"
const val EVENT_ID__VERSION = "eventId.version"
const val PROCESSOR = "processor"
const val PROCESSOR__CONTEXT_NAME = "processor.contextName"
const val PROCESSOR__PROCESSOR_NAME = "processor.processorName"
const val FUNCTION_KIND = "functionKind"
const val ERROR = "error"
const val ERROR__BINDING_ERRORS = "error.bindingErrors"
const val ERROR__ERROR_CODE = "error.errorCode"
const val ERROR__ERROR_MSG = "error.errorMsg"
const val ERROR__STACK_TRACE = "error.stackTrace"
const val ERROR__SUCCEEDED = "error.succeeded"
const val EXECUTE_AT = "executeAt"
const val RETRY_SPEC = "retrySpec"
const val RETRY_SPEC__EXECUTION_TIMEOUT = "retrySpec.executionTimeout"
const val RETRY_SPEC__MAX_RETRIES = "retrySpec.maxRetries"
const val RETRY_SPEC__MIN_BACKOFF = "retrySpec.minBackoff"
const val RETRY_STATE = "retryState"
const val RETRY_STATE__NEXT_RETRY_AT = "retryState.nextRetryAt"
const val RETRY_STATE__RETRIES = "retryState.retries"
const val RETRY_STATE__RETRY_AT = "retryState.retryAt"
const val RETRY_STATE__TIMEOUT_AT = "retryState.timeoutAt"
const val STATUS = "status"
const val RECOVERABLE = "recoverable"
const val ID = "id"
const val IS_BELOW_RETRY_THRESHOLD = "isBelowRetryThreshold"
const val IS_RETRYABLE = "isRetryable"
}