Durable SQLite change capture and resumable incremental projections for MoonBit.
Dependencies
| 组件 | 能力 |
|---|---|
| 类型模型 | NULL、Int64、有限 Double、文本、BLOB;数值字符串编码、BLOB 十六进制编码 |
| 捕获 | 普通表持久化 AFTER 触发器;事务回滚不留下事件;复合主键及主键更新 |
| 初始化 | 同一事务读取快照、水位并登记消费者 |
| 增量消费 | 源标识隔离、日志连续性检查、批次预算、确认时比较旧游标 |
| SQLite 目标 | 数据与游标同事务提交;重放不重复应用;before-image 冲突时整批回滚 |
| 筛选投影 | 类型严格的过滤器、列选择/重命名、目标持久化规则、防止恢复时偷换规则 |
| 传输 | JSON、带 header/commit 的 JSONL;增量批次解码、截断检测、分批/合批、相邻事件压缩 |
| 运维 | 暂停/恢复、消费者分叉和检查点登记、保留策略预览、分批清理、诊断、审计、安全卸载 |
moon update
moon build --target native
moon run cmd/main --target native -- help
python examples/demo.pymoon run cmd/main --target native -- plan source.db orders customers
moon run cmd/main --target native -- install source.db orders customers
moon run cmd/main --target native -- bootstrap source.db report.db reporting
moon run cmd/main --target native -- sync source.db report.db reporting
moon run cmd/main --target native -- audit source.db report.db
moon run cmd/main --target native -- status source.db
moon run cmd/main --target native -- retention source.db
moon run cmd/main --target native -- prune-bounded source.db --limit 1000let source = @sqlite.Database::open("source.db")
defer source.close()
let target = @sqlite.Database::open("report.db")
defer target.close()
source.install_capture(["orders"]) |> ignore
target.initialize_projection(source.snapshot("reporting"))
@sqlite.synchronize(source, target, "reporting") |> ignorepython scripts/verify.py
python scripts/count_loc.pypub suberror CdcError {
Invalid(String)
Conflict(String)
Stale(String)
Corrupt(String)
} derive(Debug)#deprecated("`AuditReport::equal` is deprecated, use `Eq::equal` instead.")
fn AuditReport::equal(AuditReport, AuditReport) -> Bool#deprecated("`AuditReport::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn AuditReport::not_equal(x : AuditReport, y : AuditReport) -> Bool#deprecated("`AuditReport::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn AuditReport::to_repr(AuditReport) -> Reprfn BatchDecoder::new(max_events? : Int, max_line_units? : Int, max_total_units? : Int) -> BatchDecoder raise CdcError#deprecated("`ColumnSelection::equal` is deprecated, use `Eq::equal` instead.")
fn ColumnSelection::equal(ColumnSelection, ColumnSelection) -> Bool#deprecated("`ColumnSelection::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn ColumnSelection::not_equal(x : ColumnSelection, y : ColumnSelection) -> Bool#deprecated("`ColumnSelection::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn ColumnSelection::to_repr(ColumnSelection) -> Repr#deprecated("`ProjectionPlan::equal` is deprecated, use `Eq::equal` instead.")
fn ProjectionPlan::equal(ProjectionPlan, ProjectionPlan) -> Bool#deprecated("`ProjectionPlan::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn ProjectionPlan::not_equal(x : ProjectionPlan, y : ProjectionPlan) -> Boolfn ProjectionPlan::project_snapshot(self : ProjectionPlan, snapshot : Snapshot) -> Snapshot raise CdcError#deprecated("`ProjectionPlan::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn ProjectionPlan::to_repr(ProjectionPlan) -> Repr#deprecated("`RowDifference::equal` is deprecated, use `Eq::equal` instead.")
fn RowDifference::equal(RowDifference, RowDifference) -> Bool#deprecated("`RowDifference::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn RowDifference::not_equal(x : RowDifference, y : RowDifference) -> Bool#deprecated("`RowDifference::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn RowDifference::to_repr(RowDifference) -> Reprpub(all) struct TableAudit {
table : String
expected_rows : Int
actual_rows : Int
missing : Int
unexpected : Int
changed : Int
samples : Array[RowDifference]
} derive(Eq, Debug)#deprecated("`TableAudit::equal` is deprecated, use `Eq::equal` instead.")
fn TableAudit::equal(TableAudit, TableAudit) -> Bool#deprecated("`TableAudit::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn TableAudit::not_equal(x : TableAudit, y : TableAudit) -> Bool#deprecated("`TableAudit::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn TableAudit::to_repr(TableAudit) -> Repr#deprecated("`TableSnapshot::equal` is deprecated, use `Eq::equal` instead.")
fn TableSnapshot::equal(TableSnapshot, TableSnapshot) -> Bool#deprecated("`TableSnapshot::not_equal` is deprecated, use `Eq::not_equal` instead.")
fn TableSnapshot::not_equal(x : TableSnapshot, y : TableSnapshot) -> Bool#deprecated("`TableSnapshot::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
fn TableSnapshot::to_repr(TableSnapshot) -> Reprfn compare_snapshots(expected : Snapshot, actual : Snapshot, sample_limit? : Int) -> AuditReport raise CdcErrorfn compare_table(expected : TableSnapshot, actual : TableSnapshot, sample_limit? : Int) -> TableAudit raise CdcErrorInstall
Download zipDurable SQLite change capture and resumable incremental projections for MoonBit.
Dependencies