Files
backend/internal/config/server.go
lafay a0e210feab
All checks were successful
Build Backend / build (push) Successful in 3m1s
Build Backend / build-docker (push) Successful in 2m10s
feat(server): implement chat file TTL cleanup and enhance JPush vendor channel support
Add FileCleanupWorker for automatic expiration of chat files with configurable retention period and batch processing. Files uploaded via `/api/v1/uploads/files` are tracked in `uploaded_files` table with expiration timestamps, then deleted from S3 and database upon expiry. Expired file URLs are injected as `"expired": true` in message responses.

Extend JPush push notification configuration with vendor-specific channel_id support (xiaomi, huawei, oppo, vivo, meizu, honor, fcm) for differentiating system vs chat notifications. Add iOS APNs thread-id grouping configuration for notification categorization.
2026-06-17 20:41:55 +08:00

72 lines
2.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package config
// ServerConfig 服务器配置
type ServerConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Mode string `mapstructure:"mode"`
}
// LogConfig 日志配置
type LogConfig struct {
Level string `mapstructure:"level"`
Encoding string `mapstructure:"encoding"`
OutputPaths []string `mapstructure:"output_paths"`
Retention LogRetentionConfig `mapstructure:"retention"`
Async AsyncLogConfig `mapstructure:"async"`
Sensitive SensitiveLogConfig `mapstructure:"sensitive"`
Rotation LogRotationConfig `mapstructure:"rotation"`
}
// LogRetentionConfig 日志保留配置
type LogRetentionConfig struct {
AccessLog int `mapstructure:"access_log"` // HTTP访问日志(天)
OperationLog int `mapstructure:"operation_log"` // 操作日志(天)
LoginLog int `mapstructure:"login_log"` // 登录日志(天)
DataChange int `mapstructure:"data_change"` // 数据变更日志(天)
}
// AsyncLogConfig 异步日志配置
type AsyncLogConfig struct {
BufferSize int `mapstructure:"buffer_size"` // 通道缓冲大小
BatchSize int `mapstructure:"batch_size"` // 批量写入大小
FlushInterval string `mapstructure:"flush_interval"` // 刷新间隔
WorkerCount int `mapstructure:"worker_count"` // worker数量
EnableFallback bool `mapstructure:"enable_fallback"` // 启用降级
FallbackPath string `mapstructure:"fallback_path"` // 降级文件路径
}
// SensitiveLogConfig 敏感日志配置
type SensitiveLogConfig struct {
Enabled bool `mapstructure:"enabled"` // 启用脱敏
MaskFields []string `mapstructure:"mask_fields"` // 需脱敏字段
}
// LogRotationConfig 日志轮转配置
type LogRotationConfig struct {
MaxSize int `mapstructure:"max_size"` // 单个文件最大大小(MB)
MaxAge int `mapstructure:"max_age"` // 最大保留天数
MaxBackups int `mapstructure:"max_backups"` // 最大备份数
Compress bool `mapstructure:"compress"` // 压缩
}
// RateLimitConfig 限流配置
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled"`
RequestsPerMinute int `mapstructure:"requests_per_minute"`
}
// UploadConfig 上传配置
type UploadConfig struct {
MaxFileSize int64 `mapstructure:"max_file_size"`
AllowedTypes []string `mapstructure:"allowed_types"`
}
// FileCleanupConfig 聊天文件 TTL 过期清理配置
type FileCleanupConfig struct {
Enabled bool `mapstructure:"enabled"` // 是否启用清理 worker
RetentionDays int `mapstructure:"retention_days"` // 保留天数,默认 7
IntervalMinutes int `mapstructure:"interval_minutes"` // 扫描间隔(分钟),默认 3606 小时)
BatchSize int `mapstructure:"batch_size"` // 单次扫描处理上限,默认 100
}