feat(task): 优化文件列表获取逻辑并添加缓存机制

- 实现按时间前缀获取文件列表,支持小时级目录检索
- 添加降级机制,当时间前缀方式无法找到文件时回退到按天目录
- 在适配器层添加单例模式和客户端连接池管理
- 为S3和AliOSS适配器添加文件列表缓存功能
- 修复跨天任务处理逻辑,约束业务不支持跨天操作
- 优化文件去重逻辑,避免重复处理相同文件
- 添加详细的链路追踪和错误处理机制
This commit is contained in:
2025-12-29 18:39:24 +08:00
parent 686401162f
commit 10e39a506c
5 changed files with 178 additions and 47 deletions

View File

@@ -18,28 +18,6 @@ const (
fileListCacheCleanupInterval = 1 * time.Minute
)
var (
s3FileListCacheOnce sync.Once
s3FileListCacheInstance *fileListCache
aliOssFileListCacheOnce sync.Once
aliOssFileListCacheInstance *fileListCache
)
func getS3FileListCache() *fileListCache {
s3FileListCacheOnce.Do(func() {
s3FileListCacheInstance = newFileListCache(getFileListCacheTTL(), getFileListCacheMaxEntries())
})
return s3FileListCacheInstance
}
func getAliOssFileListCache() *fileListCache {
aliOssFileListCacheOnce.Do(func() {
aliOssFileListCacheInstance = newFileListCache(getFileListCacheTTL(), getFileListCacheMaxEntries())
})
return aliOssFileListCacheInstance
}
func getFileListCacheTTL() time.Duration {
ttlSeconds := config.Config.Record.Cache.FileListTTLSeconds
if ttlSeconds <= 0 {