重构:将示例文件组织到子目录
修复 Go 规范问题:一个目录不能有多个 package main
文件结构调整:
- example/concurrent_example.go → example/concurrent/main.go
- example/index_example.go → example/index/main.go
- example/topic_processor_example.go → example/topic_processor/main.go
修复 API 适配:
- index/main.go: 更新为新的查询 API(移除 startIdx/endIdx 参数)
- webapp/main.go: 使用 processor.Query 方法替代 RecordQuery
- 移除 queryCache,直接使用 processor
- 更新查询调用,移除状态参数
文档更新:
- example/README.md: 更新所有示例的运行路径
- example/RUN_CONCURRENT.md: 更新运行命令
所有示例编译测试通过 ✅
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
## 快速开始
|
||||
|
||||
```bash
|
||||
cd example
|
||||
go run concurrent_example.go
|
||||
cd example/concurrent
|
||||
go run main.go
|
||||
```
|
||||
|
||||
## 预计运行时间
|
||||
@@ -22,7 +22,8 @@ go run concurrent_example.go
|
||||
如果想在后台运行并保存日志:
|
||||
|
||||
```bash
|
||||
go run concurrent_example.go > output.log 2>&1 &
|
||||
cd example/concurrent
|
||||
go run main.go > output.log 2>&1 &
|
||||
echo $! > pid.txt
|
||||
|
||||
# 查看实时输出
|
||||
@@ -74,7 +75,7 @@ rm pid.txt
|
||||
|
||||
## 自定义测试
|
||||
|
||||
如果想调整测试参数,编辑 `concurrent_example.go`:
|
||||
如果想调整测试参数,编辑 `concurrent/main.go`:
|
||||
|
||||
```go
|
||||
// 场景 1:每个 topic 写入的消息数
|
||||
|
||||
Reference in New Issue
Block a user