重构:将示例文件组织到子目录
修复 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:
@@ -4,7 +4,7 @@
|
||||
|
||||
## 示例列表
|
||||
|
||||
### 1. concurrent_example.go - 高并发示例
|
||||
### 1. concurrent/ - 高并发示例
|
||||
|
||||
展示 seqlog 在高并发场景下的性能表现。
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
**运行方式:**
|
||||
```bash
|
||||
go run concurrent_example.go
|
||||
cd concurrent
|
||||
go run main.go
|
||||
```
|
||||
|
||||
**注意:** 这个示例需要运行约 5 分钟,请耐心等待。
|
||||
@@ -97,7 +98,7 @@ go run concurrent_example.go
|
||||
- 多个 goroutine 可以并发查询同一或不同的 topic
|
||||
- 查询时可能遇到少量 EOF 错误(因为 tailer 正在处理文件)
|
||||
|
||||
### 2. topic_processor_example.go - TopicProcessor 基础示例
|
||||
### 2. topic_processor/ - TopicProcessor 基础示例
|
||||
|
||||
展示如何使用 TopicProcessor 作为日志聚合器。
|
||||
|
||||
@@ -109,16 +110,18 @@ go run concurrent_example.go
|
||||
|
||||
**运行方式:**
|
||||
```bash
|
||||
go run topic_processor_example.go
|
||||
cd topic_processor
|
||||
go run main.go
|
||||
```
|
||||
|
||||
### 3. index_example.go - 索引功能示例
|
||||
### 3. index/ - 索引功能示例
|
||||
|
||||
展示索引文件的使用和管理。
|
||||
|
||||
**运行方式:**
|
||||
```bash
|
||||
go run index_example.go
|
||||
cd index
|
||||
go run main.go
|
||||
```
|
||||
|
||||
### 4. webapp/ - Web 应用示例
|
||||
|
||||
Reference in New Issue
Block a user