重构:简化查询接口

- RecordQuery.QueryOldest 和 QueryNewest 不再接收 startIdx/endIdx 参数
- 查询方法返回纯 Record 列表,状态判断移到调用方
- TopicProcessor 的查询方法负责添加状态信息
- 更新所有测试文件以适配新接口
This commit is contained in:
2025-10-04 00:10:14 +08:00
parent a421ca1d85
commit 5c028a55b3
8 changed files with 168 additions and 208 deletions

View File

@@ -180,10 +180,9 @@ func TestQueryWithIndex(t *testing.T) {
t.Errorf("记录总数不正确: got %d, want 10", count)
}
// 5. 测试向后查询(需要索引
// 从第 5 条记录向后查询 3 条
offset, _ := index.GetOffset(5)
results, err := query.QueryAt(offset, -1, 3, 0, 5) // startIdx=0, endIdx=5
// 5. 测试向后查询(查询更早的记录
// 从第 5 条记录向后查询 3 条(查询索引 4, 3, 2
results, err := query.QueryNewest(4, 3)
if err != nil {
t.Fatalf("向后查询失败: %v", err)
}