You've already forked VptPassiveAdapter
- 添加 CacheConfig 结构体定义文件列表缓存的TTL和最大条目数 - 在RecordConfig中集成Cache配置项 - 为AliOSS和S3适配器实现统一的文件列表缓存机制 - 移除原有的sync.Map缓存实现和定时清理逻辑 - 引入go-cache依赖库实现专业的缓存管理功能 - 使用LRU算法控制缓存大小避免内存泄漏 - 通过singleflight实现缓存穿透保护和并发控制 - 更新配置文件添加缓存相关配置项 - 在.gitignore中添加.exe文件忽略规则
68 lines
2.0 KiB
Go
68 lines
2.0 KiB
Go
package config
|
|
|
|
type ApiConfig struct {
|
|
BaseUrl string `mapstructure:"baseUrl"`
|
|
}
|
|
|
|
type CacheConfig struct {
|
|
FileListTTLSeconds int `mapstructure:"fileListTTLSeconds"`
|
|
FileListMaxEntries int `mapstructure:"fileListMaxEntries"`
|
|
}
|
|
|
|
type RecordConfig struct {
|
|
Storage StorageConfig `mapstructure:"storage"`
|
|
Duration int `mapstructure:"duration"`
|
|
Cache CacheConfig `mapstructure:"cache"`
|
|
}
|
|
|
|
type StorageConfig struct {
|
|
Type string `mapstructure:"type"`
|
|
Path string `mapstructure:"path"`
|
|
S3 S3Config `mapstructure:"s3"`
|
|
AliOSS AliOSSConfig `mapstructure:"aliOss"`
|
|
}
|
|
|
|
type S3Config struct {
|
|
Region string `mapstructure:"region"`
|
|
Endpoint string `mapstructure:"endpoint"`
|
|
Bucket string `mapstructure:"bucket"`
|
|
Prefix string `mapstructure:"prefix"`
|
|
AkId string `mapstructure:"akId"`
|
|
AkSec string `mapstructure:"akSec"`
|
|
}
|
|
|
|
type AliOSSConfig struct {
|
|
Endpoint string `mapstructure:"endpoint"`
|
|
Bucket string `mapstructure:"bucket"`
|
|
Prefix string `mapstructure:"prefix"`
|
|
AccessKeyId string `mapstructure:"accessKeyId"`
|
|
AccessKeySecret string `mapstructure:"accessKeySecret"`
|
|
}
|
|
|
|
type DeviceMapping struct {
|
|
DeviceNo string `mapstructure:"deviceNo" json:"deviceNo"`
|
|
Name string `mapstructure:"name" json:"name"`
|
|
}
|
|
|
|
type FileNameConfig struct {
|
|
DateSeparator string `mapstructure:"dateSeparator"`
|
|
TimeSplit string `mapstructure:"timeSplit"`
|
|
FileExt string `mapstructure:"fileExt"`
|
|
UnfinishedFileExt string `mapstructure:"unFinExt"`
|
|
}
|
|
|
|
type ViidConfig struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
ServerUrl string `mapstructure:"serverUrl"`
|
|
ScenicId int64 `mapstructure:"scenicId"`
|
|
Port int `mapstructure:"port"`
|
|
}
|
|
|
|
type MainConfig struct {
|
|
Api ApiConfig `mapstructure:"api"`
|
|
Record RecordConfig `mapstructure:"record"`
|
|
Devices []DeviceMapping `mapstructure:"devices"`
|
|
FileName FileNameConfig `mapstructure:"fileName"`
|
|
Viid ViidConfig `mapstructure:"viid"`
|
|
}
|