Documentation
¶
Index ¶
- type AlgorithmLogger
- func (al *AlgorithmLogger) AddCleanupRule(tableName, timestampColumn string, retentionPeriod time.Duration)
- func (al *AlgorithmLogger) CleanupOldRecords() error
- func (al *AlgorithmLogger) Close() error
- func (al *AlgorithmLogger) GetCleanupRules() []CleanupRule
- func (al *AlgorithmLogger) GetStatistics(start, end time.Time) (*Statistics, error)
- func (al *AlgorithmLogger) RemoveCleanupRule(tableName string)
- func (al *AlgorithmLogger) SetCleanupRuleEnabled(tableName string, enabled bool)
- type CleanupRule
- type DBHelper
- func (h *DBHelper) BatchInsert(tableName string, data interface{}) error
- func (h *DBHelper) Close() error
- func (h *DBHelper) CreateTableFromStruct(tableName string, structType interface{}) error
- func (h *DBHelper) Insert(tableName string, data interface{}) error
- func (h *DBHelper) Query(query string, result interface{}, args ...interface{}) error
- func (h *DBHelper) QueryMap(query string, args ...interface{}) (map[string]interface{}, error)
- func (h *DBHelper) QueryMaps(query string, args ...interface{}) ([]map[string]interface{}, error)
- func (h *DBHelper) QueryOne(query string, result interface{}, args ...interface{}) error
- func (h *DBHelper) QueryRaw(query string, args ...interface{}) ([]map[string]interface{}, error)
- type Statistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlgorithmLogger ¶
type AlgorithmLogger struct {
DbHelper *DBHelper
CleanupRules []CleanupRule
}
AlgorithmLogger 算法数据记录器
func NewAlgorithmLogger ¶
func NewAlgorithmLogger(dbPath string) (*AlgorithmLogger, error)
NewAlgorithmLogger 创建新的算法记录器
func (*AlgorithmLogger) AddCleanupRule ¶
func (al *AlgorithmLogger) AddCleanupRule(tableName, timestampColumn string, retentionPeriod time.Duration)
AddCleanupRule 添加清理规则
func (*AlgorithmLogger) CleanupOldRecords ¶
func (al *AlgorithmLogger) CleanupOldRecords() error
cleanupOldRecords 根据配置的规则清理旧记录
func (*AlgorithmLogger) GetCleanupRules ¶
func (al *AlgorithmLogger) GetCleanupRules() []CleanupRule
GetCleanupRules 获取所有清理规则
func (*AlgorithmLogger) GetStatistics ¶
func (al *AlgorithmLogger) GetStatistics(start, end time.Time) (*Statistics, error)
GetStatistics 获取统计信息
func (*AlgorithmLogger) RemoveCleanupRule ¶
func (al *AlgorithmLogger) RemoveCleanupRule(tableName string)
RemoveCleanupRule 移除清理规则
func (*AlgorithmLogger) SetCleanupRuleEnabled ¶
func (al *AlgorithmLogger) SetCleanupRuleEnabled(tableName string, enabled bool)
SetCleanupRuleEnabled 启用/禁用清理规则
type CleanupRule ¶
type CleanupRule struct {
TableName string `json:"table_name"`
TimestampColumn string `json:"timestamp_column"`
RetentionPeriod time.Duration `json:"retention_period"`
Enabled bool `json:"enabled"`
}
CleanupRule 清理规则
type DBHelper ¶
type DBHelper struct {
// contains filtered or unexported fields
}
DBHelper 通用数据库操作辅助类
func (*DBHelper) BatchInsert ¶
BatchInsert 批量插入记录
func (*DBHelper) CreateTableFromStruct ¶
CreateTableFromStruct 根据结构体自动创建表. 使用 GORM-style 的 db 标签来定义字段属性. 标签格式: `db:"column_name;option1;option2:value;..."` 支持的选项: - primaryKey: 主键 - autoIncrement: 自增 - not null: 非空 - unique: 唯一 - index: 创建索引 - size:255: 字段大小 (用于 VARCHAR) - default:'some_value': 默认值
Click to show internal directories.
Click to hide internal directories.