Files
VptPassiveAdapter/config/dto.go
Jerry Yan 5722dd8e5a feat(core): 添加断连检测和命令执行功能
- 新增 ConnError 类型用于区分连接级错误和应用层错误
- 在 sync_task 中将网络请求错误包装为 ConnError
- 添加 DisconnectActionConfig 配置结构支持断连操作
- 在配置文件中增加 disconnectAction 配置项
- 实现 executeDisconnectCommand 函数支持跨平台命令执行
- 在主循环中添加断连检测逻辑和阈值判断
- 支持服务器连接恢复时重置断连状态
- 添加详细的日志记录用于断连状态追踪
2026-02-09 23:33:55 +08:00

75 lines
2.3 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 DisconnectActionConfig struct {
Enabled bool `mapstructure:"enabled"`
ThresholdMinutes int `mapstructure:"thresholdMinutes"`
Command string `mapstructure:"command"`
}
type MainConfig struct {
Api ApiConfig `mapstructure:"api"`
Record RecordConfig `mapstructure:"record"`
Devices []DeviceMapping `mapstructure:"devices"`
FileName FileNameConfig `mapstructure:"fileName"`
Viid ViidConfig `mapstructure:"viid"`
DisconnectAction DisconnectActionConfig `mapstructure:"disconnectAction"`
}