You've already forked VptPassiveAdapter
- 实现按时间前缀获取文件列表,支持小时级目录检索 - 添加降级机制,当时间前缀方式无法找到文件时回退到按天目录 - 在适配器层添加单例模式和客户端连接池管理 - 为S3和AliOSS适配器添加文件列表缓存功能 - 修复跨天任务处理逻辑,约束业务不支持跨天操作 - 优化文件去重逻辑,避免重复处理相同文件 - 添加详细的链路追踪和错误处理机制
40 lines
756 B
Go
40 lines
756 B
Go
package fs
|
|
|
|
import (
|
|
"ZhenTuLocalPassiveAdapter/config"
|
|
"ZhenTuLocalPassiveAdapter/dto"
|
|
"context"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
type Adapter interface {
|
|
GetFileList(ctx context.Context, path string, relDt time.Time) ([]dto.File, error)
|
|
}
|
|
|
|
var (
|
|
adapterOnce sync.Once
|
|
adapterInstance Adapter
|
|
)
|
|
|
|
func GetAdapter() Adapter {
|
|
adapterOnce.Do(func() {
|
|
if config.Config.Record.Storage.Type == "s3" {
|
|
adapterInstance = &S3Adapter{
|
|
StorageConfig: config.Config.Record.Storage,
|
|
}
|
|
return
|
|
}
|
|
if config.Config.Record.Storage.Type == "alioss" {
|
|
adapterInstance = &AliOSSAdapter{
|
|
StorageConfig: config.Config.Record.Storage,
|
|
}
|
|
return
|
|
}
|
|
adapterInstance = &LocalAdapter{
|
|
config.Config.Record.Storage,
|
|
}
|
|
})
|
|
return adapterInstance
|
|
}
|