Initial commit: archer, a Go-native MySQL/MariaDB table archiver

Renamed from arcdb: module path, cmd/archer, internal/archererr,
docs, build scripts and ARCHER_* environment variables.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
voidandClaude Sonnet 4.6 committed 2026-11-06 22:12:17 +08:00
commit bc4a6b504f
99 files changed
+12752

No files matched your search

@@ -0,0 +1,42 @@
## 1. 依赖与压缩器
- [x] 1.1 `go get github.com/ulikunitz/xz@v0.5.17`,更新 `go.mod` / `go.sum`
- [x] 1.2 `Compressor` 增加 `Level` 字段;`NewCompressor(name string, level int)` 接受档位
- [x] 1.3 实现档位映射:gzip 直传 1–9;zstd 按 1-2 fastest / 3-5 default / 6-8 better / 9 best;xz 按字典表 1/2/4/4/8/8/16/32/64 MiB
- [x] 1.4 xz writer 使用 `xz.WriterConfig{DictCap: ...}`;reader 固定 `DictCap 64 MiB` 并保留多 stream 解码
## 2. CLI
- [x] 2.1 `cli/config.go`:`CompressLevel int`,默认 3
- [x] 2.2 `cli/parse.go`:注册 `--compress-level`,help 标注 1–9
- [x] 2.3 `cli/validate.go`:档位必须在 1–9;`--compress none` 且档位非 3 时报配置错误
- [x] 2.4 `cli/hash.go`:仅当 `compress != none && level != 3` 时加入 `compress_level`
## 3. 装配与扩展名收敛
- [x] 3.1 `app/app.go`:用 `NewCompressor(cfg.Compress, cfg.CompressLevel)` 构造
- [x] 3.2 `app/dryrun.go`:输出压缩档位;删除 `compressExt()`,改用 `Compressor.Ext`
## 4. 崩溃恢复
- [x] 4.1 `shard/manifest.go`:`shardNameRE` 增加 `\.xz`,`Adopt` 能识别 xz 分片并计入序号
## 5. 测试
- [x] 5.1 档位映射边界单测(含 gzip/zstd/xz 与非法档位)
- [x] 5.2 `shard/writer_test.go` 的压缩往返循环加入 `xz`
- [x] 5.3 新增:`Checkpoint()` 后多 stream xz 分片能被完整读回
- [x] 5.4 新增:无 manifest 记录的 `.xz` 分片可被 `Adopt` 补录且不影响序号
- [x] 5.5 CLI 测试:非法档位、`none` + 非默认档位、默认档位的指纹向后兼容、非默认档位变化被拒绝
- [x] 5.6 `app/integration_test.go`:压缩循环加入 `xz`,`decompressFile` 增加 xz 分支
## 6. 文档
- [x] 6.1 `README.md`:压缩选项加入 xz 与 `--compress-level`,补档位表、xz 导入示例(`xz -dc`)与 xz 吞吐/空间定位说明
## 7. 验证
- [x] 7.1 `go test ./...`
- [x] 7.2 `go vet ./...`
- [x] 7.3 `openspec validate add-compress-level-and-xz --strict`
- [ ] 7.4 如有 MySQL 环境,跑一次 `ARCHER_TEST_DSN=... go test ./internal/app -run TestIntegration -v`