Documentation
¶
Overview ¶
Package migration 提供 Java 存量数据库的只读迁移风险预检。
Package migration 提供既有 Java 数据库的只读迁移预检。
Index ¶
Constants ¶
const StateFormat = "flowtide-state"
StateFormat 是离线状态文件的格式标识,与 -convert 报告中的 preparedState.format 保持一致。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CutoverReport ¶
type CutoverReport struct {
Dialect string `json:"dialect"` // 数据库方言
SchemaVersion string `json:"schemaVersion"` // 窗口前快照读取的源库版本
WindowSeconds float64 `json:"windowSeconds"` // 观察窗口秒数
Stable bool `json:"stable"` // 窗口内是否未观察到写入或作业推进
ScanTimes []string `json:"scanTimes"` // 两次快照完成时间,RFC3339Nano
Tables []TableQuiescence `json:"tables"` // 表级前后行数与内容摘要
ChangedTables []string `json:"changedTables"` // 发生变化的表名,按字典序
JobCounts []JobCountQuiescence `json:"jobCounts"` // 六类作业表前后计数
Limitations []string `json:"limitations"` // 检查边界与无法覆盖的内容
}
CutoverReport 描述停写切换前的只读静默检查结果;只包含表名、计数与指纹摘要。
func CheckQuiescence ¶
func CheckQuiescence(ctx context.Context, db *sql.DB, dialect string, window time.Duration) (CutoverReport, error)
CheckQuiescence 在观察窗口前后各做一次只读扫描,比较行数与内容指纹判断源库是否静默。 @param ctx 检查上下文,取消后不返回部分报告 @param db 已连接的源数据库 @param dialect 数据库方言,仅支持 mysql 和 postgres @param window 观察窗口,必须大于零 @return 完整静默检查报告,失败时为空报告 @return 参数、扫描、取消或数据库错误
type Issue ¶
type Issue struct {
Code string `json:"code"`
Table string `json:"table"`
EntityID string `json:"entityId"`
TenantID string `json:"tenantId"`
ProcessInstanceID string `json:"processInstanceId"`
Message string `json:"message"`
Blocking bool `json:"blocking"`
}
Issue 记录不包含业务值和源码的逐实体迁移问题。
type JobCountQuiescence ¶
type JobCountQuiescence struct {
Table string `json:"table"` // 作业表名
Before int64 `json:"before"` // 窗口前行数,表不存在时为零
After int64 `json:"after"` // 窗口后行数,表不存在时为零
}
JobCountQuiescence 表示一张作业表在观察窗口前后的行数。
type PreparedStateSummary ¶
type PreparedStateSummary struct {
Format string `json:"format"` // 状态格式
SHA256 string `json:"sha256"` // 状态字节摘要
Bytes int `json:"bytes"` // 状态字节数
SourceRows int `json:"sourceRows"` // 全库扫描实体行数,不含仅统计的表
ConvertedRows int `json:"convertedRows"` // 本次进入状态恢复的实体行数
}
PreparedStateSummary 绑定离线准备的 Go 状态制品,不表示源引擎已停写或完成切换。
type ReconcileReport ¶
type ReconcileReport struct {
Matched bool `json:"matched"` // 所有可转换内容是否一致
StateSHA256 string `json:"stateSha256"` // 被核对状态文件摘要
SourceRows int `json:"sourceRows"` // 同一只读快照中的已扫描行数
Tables []StateTableComparison `json:"tables"` // 确定排序的表级核对
ChangedTables []string `json:"changedTables"` // 内容或数量不同的表
Limitations []string `json:"limitations"` // 固定边界说明
}
ReconcileReport 仅返回计数和摘要,不包含业务值、源码或凭据。
func ReconcileState ¶
func ReconcileState(ctx context.Context, source SourceSnapshot, data []byte, options Options) (ReconcileReport, error)
ReconcileState 将同一源快照重新转换为预期状态,与待接管状态的完整行投影比较。 @param ctx 核对上下文 @param source 同一只读事务扫描的源快照,调用方须另行保证源执行者已停写 @param data 待接管状态文件字节 @param options 目标租户范围,与转换时一致 @return 逐表数量与内容指纹报告 @return 预检阻断、转换、恢复或取消错误
type Report ¶
type Report struct {
Baseline string `json:"baseline"`
SchemaVersion string `json:"schemaVersion"`
Dialect string `json:"dialect"`
Blocked bool `json:"blocked"`
Issues []Issue `json:"issues"`
Tenants []TenantSummary `json:"tenants"`
Tables []TableSummary `json:"tables"`
Scope string `json:"scope"`
RequestedTenantID *string `json:"requestedTenantId,omitempty"`
Limitations []string `json:"limitations"`
PreparedState *PreparedStateSummary `json:"preparedState,omitempty"`
}
Report 描述来源基线、只读分析范围及阻断问题,不代表续跑验收通过。
func Analyze ¶
func Analyze(snapshot SourceSnapshot, options Options) Report
Analyze 逐实体检查 Java 来源快照并给出保守的迁移阻断报告。 @param snapshot 一致性只读来源快照 @param options 租户范围 @return 不含变量值、二进制及源码的风险报告
type SourceSnapshot ¶
type SourceSnapshot struct {
Dialect string `json:"dialect"` // 数据库方言
SchemaVersion string `json:"schemaVersion"` // 源库版本
Tables []TableSummary `json:"tables"` // 各表统计
Rows []flowable.Row `json:"-"` // 仅供进程内分析的行
}
SourceSnapshot 保存同一只读事务取得的源库结构和行数据;行数据不参与报告序列化。
type StateReport ¶
type StateReport struct {
Format string `json:"format"` // 状态格式标识
Version int `json:"version"` // 状态格式版本
Bytes int `json:"bytes"` // 状态文件字节数
SHA256 string `json:"sha256"` // 状态文件 SHA-256 摘要
Deployments int `json:"deployments"` // 部署数量
Definitions int `json:"definitions"` // 流程定义数量
RunningInstances int `json:"runningInstances"` // 运行中流程实例数量
EndedInstances int `json:"endedInstances"` // 已结束历史流程实例数量
Tasks int `json:"tasks"` // 当前用户任务数量
HistoricProcessInstances int `json:"historicProcessInstances"` // 历史流程实例数量
HistoricTaskInstances int `json:"historicTaskInstances"` // 历史任务数量
HistoricVariables int `json:"historicVariables"` // 历史变量数量
SequenceFlowHistory bool `json:"sequenceFlowHistory"` // 状态是否带顺序流历史标记
Limitations []string `json:"limitations"` // 校验边界与无法覆盖的内容
}
StateReport 描述离线状态文件的只读恢复校验结果,不包含变量值、部署源码或连接凭据。
func VerifyState ¶
func VerifyState(ctx context.Context, data []byte) (StateReport, error)
VerifyState 在隔离内存引擎中恢复离线状态文件并汇总实体数量,不连接数据库也不写回文件。 @param ctx 校验上下文,取消或超时后返回错误 @param data 离线状态文件原始字节,函数不会修改输入 @return 完整状态报告,任何解析、恢复或统计失败时为零值报告 @return 空文件、JSON、版本、恢复、统计或取消错误
type StateTableComparison ¶
type StateTableComparison struct {
Table string `json:"table"` // 表名称
ExpectedRows int `json:"expectedRows"` // 源快照转换后的行数
ActualRows int `json:"actualRows"` // 状态恢复后的行数
ExpectedFingerprint string `json:"expectedFingerprint"` // 预期内容指纹
ActualFingerprint string `json:"actualFingerprint"` // 实际内容指纹
Matched bool `json:"matched"` // 数量及内容均一致
}
StateTableComparison 表示源库预期转换结果和待接管状态的逐表核对。
type TableQuiescence ¶
type TableQuiescence struct {
Name string `json:"name"` // 规范化的大写表名
BeforeRows int64 `json:"beforeRows"` // 窗口前快照行数
AfterRows int64 `json:"afterRows"` // 窗口后快照行数
ContentCompared bool `json:"contentCompared"` // 是否具备逐行内容指纹
BeforeFingerprint string `json:"beforeFingerprint,omitempty"` // 窗口前内容指纹摘要
AfterFingerprint string `json:"afterFingerprint,omitempty"` // 窗口后内容指纹摘要
Changed bool `json:"changed"` // 行数或内容是否变化
}
TableQuiescence 表示一张源表在观察窗口前后的行数与内容摘要。
type TableSummary ¶
type TableSummary struct {
Name string `json:"name"` // 规范化的大写表名
Count int64 `json:"count"` // 源行数
}
TableSummary 表示一张源表的实际行数。