11 Commits
dev ... v0.13.8

Author SHA1 Message Date
34b7a8a5df Merge pull request 'dev' (#37) from dev into main
Reviewed-on: #37
2026-02-25 15:08:43 +08:00
33a6aca4ff Merge pull request '[🚀] storage' (#36) from dev into main
Reviewed-on: #36
2026-02-07 16:27:33 +08:00
8d2de46efa Merge pull request 'dev' (#35) from dev into main
Reviewed-on: #35
2026-02-07 16:04:39 +08:00
8c8c98b756 Merge pull request '[🚀] EncryptedRequest' (#34) from dev into main
Reviewed-on: #34
2026-02-07 15:54:50 +08:00
d36d66bbf7 Merge pull request 'dev' (#33) from dev into main
Reviewed-on: #33
2026-02-07 15:45:06 +08:00
3b4b9952dc Merge pull request '[🚀] mysql' (#32) from dev into main
Reviewed-on: #32
2026-02-07 15:36:57 +08:00
b3e319a21f Merge pull request 'dev' (#31) from dev into main
Reviewed-on: #31
2026-01-21 16:41:13 +08:00
5213f7002f Merge pull request '[🚀] v0.13.1' (#30) from dev into main
Reviewed-on: #30
2025-12-20 10:45:41 +08:00
20f500ebcf Merge pull request '[🚀] v0.13.0' (#29) from dev into main
Reviewed-on: #29
2025-12-19 15:52:59 +08:00
fd13fafd86 Merge pull request 'dev' (#28) from dev into main
Reviewed-on: #28
2025-12-09 15:39:26 +08:00
8926ec889b Merge pull request '[🚀] v0.12.27' (#27) from dev into main
Reviewed-on: #27
2025-09-25 13:46:51 +08:00
5 changed files with 78 additions and 65 deletions

37
pkg/cache/redis.go vendored
View File

@@ -93,20 +93,29 @@ type RedisRepo interface {
// RedisConfig Redis配置 // RedisConfig Redis配置
type RedisConfig struct { type RedisConfig struct {
Addr string `yaml:"addr" json:"addr" mapstructure:"addr"` // 基础配置
Password string `yaml:"password" json:"password" mapstructure:"password"` Addr string `yaml:"addr" json:"addr"` // 地址,如: localhost:6379
DB int `yaml:"db" json:"db" mapstructure:"db"` Password string `yaml:"password" json:"password"` // 密码
PoolSize int `yaml:"pool_size" json:"pool_size" mapstructure:"pool_size"` DB int `yaml:"db" json:"db"` // 数据库编号
MinIdleConns int `yaml:"min_idle_conns" json:"min_idle_conns" mapstructure:"min_idle_conns"`
DialTimeout time.Duration `yaml:"dial_timeout" json:"dial_timeout" mapstructure:"dial_timeout"` // 连接池配置
ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout" mapstructure:"read_timeout"` PoolSize int `yaml:"pool_size" json:"pool_size"` // 最大连接数
WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout" mapstructure:"write_timeout"` MinIdleConns int `yaml:"min_idle_conns" json:"min_idle_conns"` // 最小空闲连接数
PoolTimeout time.Duration `yaml:"pool_timeout" json:"pool_timeout" mapstructure:"pool_timeout"`
MaxRetries int `yaml:"max_retries" json:"max_retries" mapstructure:"max_retries"` // 超时配置
MinRetryBackoff time.Duration `yaml:"min_retry_backoff" json:"min_retry_backoff" mapstructure:"min_retry_backoff"` DialTimeout time.Duration `yaml:"dial_timeout" json:"dial_timeout"` // 连接超时
MaxRetryBackoff time.Duration `yaml:"max_retry_backoff" json:"max_retry_backoff" mapstructure:"max_retry_backoff"` ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout"` // 读超时
ConnMaxIdleTime time.Duration `yaml:"conn_max_idle_time" json:"conn_max_idle_time" mapstructure:"conn_max_idle_time"` WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout"` // 写超时
ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime" json:"conn_max_lifetime" mapstructure:"conn_max_lifetime"` PoolTimeout time.Duration `yaml:"pool_timeout" json:"pool_timeout"` // 连接池超时
// 重试配置
MaxRetries int `yaml:"max_retries" json:"max_retries"` // 最大重试次数
MinRetryBackoff time.Duration `yaml:"min_retry_backoff" json:"min_retry_backoff"` // 最小重试间隔
MaxRetryBackoff time.Duration `yaml:"max_retry_backoff" json:"max_retry_backoff"` // 最大重试间隔
// 连接存活
ConnMaxIdleTime time.Duration `yaml:"conn_max_idle_time" json:"conn_max_idle_time"` // 最大空闲时间
ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime" json:"conn_max_lifetime"` // 最大生命周期
} }
// DefaultRedisConfig 默认配置 // DefaultRedisConfig 默认配置

View File

@@ -24,13 +24,13 @@ type Signer interface {
} }
type Config struct { type Config struct {
SecretKey string `yaml:"secret_key" json:"secret_key" mapstructure:"secret_key"` SecretKey string `yaml:"secret_key" json:"secret_key"` // AES对称加密密钥
SignKey string `yaml:"sign_key" json:"sign_key" mapstructure:"sign_key"` SignKey string `yaml:"sign_key" json:"sign_key"` // 签名密钥
PublicKey string `yaml:"public_key" json:"public_key" mapstructure:"public_key"` PublicKey string `yaml:"public_key" json:"public_key"` // RSA公钥
PrivateKey string `yaml:"private_key" json:"private_key" mapstructure:"private_key"` PrivateKey string `yaml:"private_key" json:"private_key"` // RSA私钥
TimestampWindow time.Duration `yaml:"timestamp_window" json:"timestamp_window" mapstructure:"timestamp_window"` TimestampWindow time.Duration `yaml:"timestamp_window" json:"timestamp_window"` // 时间戳允许的时间窗口
EnableTimestamp bool `yaml:"enable_timestamp" json:"enable_timestamp" mapstructure:"enable_timestamp"` EnableTimestamp bool `yaml:"enable_timestamp" json:"enable_timestamp"` // 是否启用时间戳验证
EnableSignature bool `yaml:"enable_signature" json:"enable_signature" mapstructure:"enable_signature"` EnableSignature bool `yaml:"enable_signature" json:"enable_signature"` // 是否启用签名
} }
type EncryptedRequest struct { type EncryptedRequest struct {

View File

@@ -49,41 +49,45 @@ type DBStats struct {
Write sql.DBStats `json:"write"` Write sql.DBStats `json:"write"`
} }
// MySQLConfig MySQL配置
type MySQLConfig struct { type MySQLConfig struct {
Read DBConnConfig `yaml:"read" json:"read" mapstructure:"read"` Read DBConnConfig `yaml:"read" json:"read"`
Write DBConnConfig `yaml:"write" json:"write" mapstructure:"write"` Write DBConnConfig `yaml:"write" json:"write"`
Base BaseConfig `yaml:"base" json:"base" mapstructure:"base"` Base BaseConfig `yaml:"base" json:"base"`
Logger LoggerConfig `yaml:"logger" json:"logger" mapstructure:"logger"` Logger LoggerConfig `yaml:"logger" json:"logger"`
} }
// DBConnConfig 数据库连接配置
type DBConnConfig struct { type DBConnConfig struct {
Addr string `yaml:"addr" json:"addr" mapstructure:"addr"` Addr string `yaml:"addr" json:"addr"`
User string `yaml:"user" json:"user" mapstructure:"user"` User string `yaml:"user" json:"user"`
Pass string `yaml:"pass" json:"pass" mapstructure:"pass"` Pass string `yaml:"pass" json:"pass"`
Name string `yaml:"name" json:"name" mapstructure:"name"` Name string `yaml:"name" json:"name"`
Charset string `yaml:"charset" json:"charset" mapstructure:"charset"` Charset string `yaml:"charset" json:"charset"` // 默认 utf8mb4
Collation string `yaml:"collation" json:"collation" mapstructure:"collation"` Collation string `yaml:"collation" json:"collation"` // 默认 utf8mb4_unicode_ci
Loc string `yaml:"loc" json:"loc" mapstructure:"loc"` Loc string `yaml:"loc" json:"loc"` // 默认 Local
ParseTime bool `yaml:"parse_time" json:"parse_time" mapstructure:"parse_time"` ParseTime bool `yaml:"parse_time" json:"parse_time"` // 默认 true
Timeout time.Duration `yaml:"timeout" json:"timeout" mapstructure:"timeout"` Timeout time.Duration `yaml:"timeout" json:"timeout"` // 连接超时(秒)
ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout" mapstructure:"read_timeout"` ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout"` // 读超时(秒)
WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout" mapstructure:"write_timeout"` WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout"` // 写超时(秒)
} }
// BaseConfig 基础配置
type BaseConfig struct { type BaseConfig struct {
MaxOpenConn int `yaml:"max_open_conn" json:"max_open_conn" mapstructure:"max_open_conn"` MaxOpenConn int `yaml:"max_open_conn" json:"max_open_conn"`
MaxIdleConn int `yaml:"max_idle_conn" json:"max_idle_conn" mapstructure:"max_idle_conn"` MaxIdleConn int `yaml:"max_idle_conn" json:"max_idle_conn"`
ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime" json:"conn_max_lifetime" mapstructure:"conn_max_lifetime"` ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime" json:"conn_max_lifetime"` // 秒
ConnMaxIdleTime time.Duration `yaml:"conn_max_idle_time" json:"conn_max_idle_time" mapstructure:"conn_max_idle_time"` ConnMaxIdleTime time.Duration `yaml:"conn_max_idle_time" json:"conn_max_idle_time"` // 秒
} }
// LoggerConfig 日志配置
type LoggerConfig struct { type LoggerConfig struct {
SlowThreshold time.Duration `yaml:"slow_threshold" json:"slow_threshold" mapstructure:"slow_threshold"` SlowThreshold time.Duration `yaml:"slow_threshold" json:"slow_threshold"`
Colorful bool `yaml:"colorful" json:"colorful" mapstructure:"colorful"` Colorful bool `yaml:"colorful" json:"colorful"`
IgnoreRecordNotFoundError bool `yaml:"ignore_record_not_found_error" json:"ignore_record_not_found_error" mapstructure:"ignore_record_not_found_error"` IgnoreRecordNotFoundError bool `yaml:"ignore_record_not_found_error" json:"ignore_record_not_found_error"`
LogLevel string `yaml:"log_level" json:"log_level" mapstructure:"log_level"` LogLevel string `yaml:"log_level" json:"log_level"`
LogOutput string `yaml:"log_output" json:"log_output" mapstructure:"log_output"` LogOutput string `yaml:"log_output" json:"log_output"` // stdout, file
LogFile string `yaml:"log_file" json:"log_file" mapstructure:"log_file"` LogFile string `yaml:"log_file" json:"log_file"` // 日志文件路径
} }
// DefaultMySQLConfig 默认配置 // DefaultMySQLConfig 默认配置
@@ -390,9 +394,9 @@ func buildDSN(conn DBConnConfig) string {
conn.Collation, conn.Collation,
conn.ParseTime, conn.ParseTime,
conn.Loc, conn.Loc,
int(conn.Timeout.Seconds()), int(conn.Timeout),
int(conn.ReadTimeout.Seconds()), int(conn.ReadTimeout),
int(conn.WriteTimeout.Seconds()), int(conn.WriteTimeout),
) )
} }

View File

@@ -18,14 +18,14 @@ import (
// Config MinIO配置 // Config MinIO配置
type Config struct { type Config struct {
Endpoint string `yaml:"endpoint" json:"endpoint" mapstructure:"endpoint"` Endpoint string `yaml:"endpoint" json:"endpoint"` // MinIO地址
AccessKeyID string `yaml:"access_key_id" json:"access_key_id" mapstructure:"access_key_id"` AccessKeyID string `yaml:"access_key_id" json:"access_key_id"` // AccessKey
SecretAccessKey string `yaml:"secret_access_key" json:"secret_access_key" mapstructure:"secret_access_key"` SecretAccessKey string `yaml:"secret_access_key" json:"secret_access_key"` // SecretKey
UseSSL bool `yaml:"use_ssl" json:"use_ssl" mapstructure:"use_ssl"` UseSSL bool `yaml:"use_ssl" json:"use_ssl"` // 是否使用SSL
BucketName string `yaml:"bucket_name" json:"bucket_name" mapstructure:"bucket_name"` BucketName string `yaml:"bucket_name" json:"bucket_name"` // 默认桶名称
Region string `yaml:"region" json:"region" mapstructure:"region"` Region string `yaml:"region" json:"region"` // 区域
CDNDomain string `yaml:"cdn_domain" json:"cdn_domain" mapstructure:"cdn_domain"` CDNDomain string `yaml:"cdn_domain" json:"cdn_domain"` // CDN域名可选
PresignExpires time.Duration `yaml:"presign_expires" json:"presign_expires" mapstructure:"presign_expires"` PresignExpires time.Duration `yaml:"presign_expires" json:"presign_expires"` // 预签名URL过期时间默认15分钟
} }
// Client MinIO客户端 // Client MinIO客户端

View File

@@ -23,14 +23,14 @@ import (
// Config S3配置 // Config S3配置
type Config struct { type Config struct {
Endpoint string `yaml:"endpoint" json:"endpoint" mapstructure:"endpoint"` Endpoint string `yaml:"endpoint" json:"endpoint"` // S3地址可选留空使用AWS
AccessKeyID string `yaml:"access_key_id" json:"access_key_id" mapstructure:"access_key_id"` AccessKeyID string `yaml:"access_key_id" json:"access_key_id"` // AccessKey
SecretAccessKey string `yaml:"secret_access_key" json:"secret_access_key" mapstructure:"secret_access_key"` SecretAccessKey string `yaml:"secret_access_key" json:"secret_access_key"` // SecretKey
UseSSL bool `yaml:"use_ssl" json:"use_ssl" mapstructure:"use_ssl"` UseSSL bool `yaml:"use_ssl" json:"use_ssl"` // 是否使用SSL
BucketName string `yaml:"bucket_name" json:"bucket_name" mapstructure:"bucket_name"` BucketName string `yaml:"bucket_name" json:"bucket_name"` // 默认桶名称
Region string `yaml:"region" json:"region" mapstructure:"region"` Region string `yaml:"region" json:"region"` // 区域
CDNDomain string `yaml:"cdn_domain" json:"cdn_domain" mapstructure:"cdn_domain"` CDNDomain string `yaml:"cdn_domain" json:"cdn_domain"` // CDN域名可选
PresignExpires time.Duration `yaml:"presign_expires" json:"presign_expires" mapstructure:"presign_expires"` PresignExpires time.Duration `yaml:"presign_expires" json:"presign_expires"` // 预签名URL过期时间默认15分钟
} }
// Client S3客户端 // Client S3客户端