Documentation
¶
Index ¶
- Variables
- func CloseAllRedisClients()
- func EnsureLockerClient(rc RedisConnectOptions) (*redis.Client, error)
- func EnsureQueueConsumerClient(rc RedisConnectOptions) (*redis.Client, error)
- func EnsureQueueProducerClient(rc RedisConnectOptions) (*redis.Client, error)
- func EnsureRedisClient(rc RedisConnectOptions) (*redis.Client, error)
- func EnsureSubscriberClient(rc RedisConnectOptions) (*redis.Client, error)
- func GetLockerClient() *redis.Client
- func GetQueueConsumerClient() *redis.Client
- func GetQueueProducerClient() *redis.Client
- func GetRedisClient() *redis.Client
- func GetSubscriberClient() *redis.Client
- func IsRedisHealthy() bool
- func ResetRedisClientsForTest()
- func SetRedisClient(c *redis.Client)
- func Setup(configYml string) error
- func StartRedisHealthCheck(ctx context.Context, interval time.Duration)
- func StopRedisHealthCheck()
- type Application
- type BacklogDetectionConfig
- type Cache
- type ClientMiddlewaresConfig
- type Config
- type ConsumerConfig
- type Database
- type DefaultTenantConfig
- func (dtc *DefaultTenantConfig) GetActiveFTPConfigs() []TenantFTPDetailConfig
- func (dtc *DefaultTenantConfig) GetDefaultTenantDomain() *TenantDomainConfig
- func (dtc *DefaultTenantConfig) GetDefaultTenantStorage() *TenantStorageDetailConfig
- func (dtc *DefaultTenantConfig) GetFTPConfigByUsername(username string) *TenantFTPDetailConfig
- func (dtc *DefaultTenantConfig) GetFTPConfigs() []TenantFTPDetailConfig
- func (dtc *DefaultTenantConfig) GetServiceDatabase(serviceCode string) *TenantDatabaseDetailConfig
- func (dtc *DefaultTenantConfig) GetServiceDatabases() map[string]TenantDatabaseDetailConfig
- func (dtc *DefaultTenantConfig) GetWvpConfig() *TenantWvpDetailConfig
- func (dtc *DefaultTenantConfig) HasFTPConfigs() bool
- func (dtc *DefaultTenantConfig) HasServiceDatabases() bool
- type DuplicateCheckConfig
- type DuplicateContentConfig
- type DuplicateFilenameConfig
- type ETCDConfig
- type ETCDTenantConfig
- type ErrorHandlingConfig
- type EventBusConfig
- type FTPConfig
- func (f *FTPConfig) FindUser(username string) *FTPUserConfig
- func (f *FTPConfig) GetConnectionTimeout() int
- func (f *FTPConfig) GetIdleTimeout() int
- func (f *FTPConfig) GetListenAddr() string
- func (f *FTPConfig) GetPassivePortEnd() int
- func (f *FTPConfig) GetPassivePortStart() int
- func (f *FTPConfig) GetPublicHost() string
- func (f *FTPConfig) GetTLSCertFile() string
- func (f *FTPConfig) GetTLSKeyFile() string
- func (f *FTPConfig) GetUsers() []FTPUserConfig
- func (f *FTPConfig) IsTLSEnabled() bool
- type FTPResolverConfig
- type FTPTLSConfig
- type FTPUserConfig
- type GRPCClientConfig
- type GRPCConfig
- type GRPCServerConfig
- type HTTPConfig
- type HTTPResolverConfig
- type HealthCheckConfig
- type HealthCheckPublisherConfig
- type HealthCheckSubscriberConfig
- type JWTConfig
- type JetStreamConfig
- type KafkaConfig
- type KeepAliveConfig
- type Locker
- type Logger
- type MemoryConfig
- type MetricsConfig
- type NATSConfig
- type NATSConsumerConfig
- type NATSSecurityConfig
- type NSQOptions
- type PortRange
- type ProducerConfig
- type PublisherBacklogDetectionConfig
- type PublisherConfig
- type Queue
- type QueueMemory
- type QueueNSQ
- type QueueRedis
- type RateLimitConfig
- type Redis
- type RedisConnectOptions
- type RedisHealth
- type Register
- type ResolverConfig
- type SSL
- type SSLConfig
- type SecurityConfig
- type ServerMiddlewaresConfig
- type ServiceConfig
- type StorageConfig
- type StreamConfig
- type SubscriberBacklogDetectionConfig
- type SubscriberConfig
- type TLSConfig
- type TenantDatabaseDetailConfig
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnMaxIdleTime() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnMaxLifeTime() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnectTimeout() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnectionString() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseDriver() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseHost() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseMaxIdleConns() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseMaxOpenConns() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseName() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabasePassword() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabasePort() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseReadTimeout() int
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseSSLMode() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseUsername() string
- func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseWriteTimeout() int
- type TenantDomainConfig
- type TenantFTPDetailConfig
- func (ftpConfig *TenantFTPDetailConfig) GetFTPDescription() string
- func (ftpConfig *TenantFTPDetailConfig) GetFTPInitialPassword() string
- func (ftpConfig *TenantFTPDetailConfig) GetFTPStatus() string
- func (ftpConfig *TenantFTPDetailConfig) GetFTPUsername() string
- func (ftpConfig *TenantFTPDetailConfig) IsFTPActive() bool
- type TenantStorageDetailConfig
- type TenantWvpDetailConfig
- type Tenants
- type TenantsStorageConfig
- type Tls
- type TracingConfig
Constants ¶
This section is empty.
Variables ¶
var AppConfig = &Config{ Application: ApplicationConfig, Logger: LoggerConfig, HTTP: HttpConfig, GRPC: GrpcConfig, Etcd: EtcdConfig, JWT: JwtConfig, Database: DatabaseConfig, Cache: CacheConfig, Queue: QueueConfig, Locker: LockerConfig, EventBus: nil, Tenants: TenantsConfig, Storage: StorageConfigInstance, DuplicateCheck: DuplicateCheckConfigInstance, FTP: FTPConfigInstance, }
var ApplicationConfig = new(Application)
var CacheConfig = new(Cache)
var (
DatabaseConfig = new(Database)
)
var DuplicateCheckConfigInstance = new(DuplicateCheckConfig)
var EtcdConfig = new(ETCDConfig)
var FTPConfigInstance = new(FTPConfig)
FTPConfig FTP 服务器配置
var GrpcConfig = new(GRPCConfig)
var HttpConfig = new(HTTPConfig)
var JwtConfig = new(JWTConfig)
var LockerConfig = new(Locker)
var LoggerConfig = new(Logger)
var QueueConfig = new(Queue)
var ServiceConfigMap = make(map[string]ServiceConfig)
var SslConfig = new(SSL)
var StorageConfigInstance = new(StorageConfig)
var TenantsConfig = new(Tenants)
Functions ¶
func CloseAllRedisClients ¶ added in v1.1.51
func CloseAllRedisClients()
CloseAllRedisClients closes all five Redis clients and resets them to nil. This is the primary teardown path for all clients. SetRedisClient also closes a replaced cache client to prevent connection pool leaks.
func EnsureLockerClient ¶ added in v1.1.52
func EnsureLockerClient(rc RedisConnectOptions) (*redis.Client, error)
EnsureLockerClient returns the locker client (independent pool from cache).
func EnsureQueueConsumerClient ¶ added in v1.1.51
func EnsureQueueConsumerClient(rc RedisConnectOptions) (*redis.Client, error)
EnsureQueueConsumerClient returns the queue consumer client, creating it if necessary. Idempotent on its own global slot — no cross-consumer conflict check.
func EnsureQueueProducerClient ¶ added in v1.1.52
func EnsureQueueProducerClient(rc RedisConnectOptions) (*redis.Client, error)
EnsureQueueProducerClient returns the queue producer client (separate pool from the consumer so non-blocking XADD isn't starved by blocking XREADGROUP).
func EnsureRedisClient ¶ added in v1.1.51
func EnsureRedisClient(rc RedisConnectOptions) (*redis.Client, error)
EnsureRedisClient returns the cache client, creating it if necessary. MasterName non-empty => Sentinel FailoverClient; otherwise standalone. Only cache wires this.
func EnsureSubscriberClient ¶ added in v1.1.51
func EnsureSubscriberClient(rc RedisConnectOptions) (*redis.Client, error)
EnsureSubscriberClient returns the subscriber client, creating it if necessary. Best-effort Ping: newClient()/NewFailoverClient() are lazy (only TLS/config errors fail); even if the initial Ping fails, the client is stored so GetSubscriberClient() is always non-nil and casbin's PSubscribe can self-heal via go-redis reconnect + mux backoff.
func GetLockerClient ¶ added in v1.1.52
GetLockerClient returns the locker client with a read lock.
func GetQueueConsumerClient ¶ added in v1.1.51
GetQueueConsumerClient returns Client #2 (queue consumer) with a read lock.
func GetQueueProducerClient ¶ added in v1.1.52
GetQueueProducerClient returns the queue producer client with a read lock.
func GetRedisClient ¶
GetRedisClient returns Client #1 (shared) with a read lock. For initialization, use EnsureRedisClient instead.
func GetSubscriberClient ¶ added in v1.1.51
GetSubscriberClient returns Client #3 (subscriber) with a read lock.
func IsRedisHealthy ¶ added in v1.1.51
func IsRedisHealthy() bool
IsRedisHealthy returns whether the Redis connection is healthy based on the most recent health check.
func ResetRedisClientsForTest ¶ added in v1.1.51
func ResetRedisClientsForTest()
ResetRedisClientsForTest clears all global Redis clients WITHOUT closing them. For use in tests only — allows resetting global state between test cases without triggering actual network operations on mock clients.
func SetRedisClient ¶
SetRedisClient sets Client #1 (for external injection). If the new client differs from the existing one, the previous client is closed (connection pool released) after the lock is released, so the close does not block concurrent readers. This uses Close() — not Shutdown() — because Shutdown() sends the Redis SERVER a SHUTDOWN command, killing the entire Redis process, whereas Close() only releases the local connection pool.
func StartRedisHealthCheck ¶ added in v1.1.51
StartRedisHealthCheck starts a background goroutine that periodically pings the Redis server and updates the health status. It stops when ctx is cancelled or StopRedisHealthCheck is called. Calling StartRedisHealthCheck twice cancels the previous checker first.
func StopRedisHealthCheck ¶ added in v1.1.51
func StopRedisHealthCheck()
StopRedisHealthCheck stops the background health checker goroutine.
Types ¶
type Application ¶
type Application struct {
Mode string `mapstructure:"mode" json:"mode"` // 环境: dev, test, prod
Name string `mapstructure:"name" json:"name"` // 应用名称
EnableDP bool `mapstructure:"enabledp" json:"enabledp"` // 数据权限功能开关
}
Application 应用程序配置
type BacklogDetectionConfig ¶ added in v1.1.19
type BacklogDetectionConfig struct {
Enabled bool `mapstructure:"enabled"`
MaxLagThreshold int64 `mapstructure:"maxLagThreshold"`
MaxTimeThreshold time.Duration `mapstructure:"maxTimeThreshold"`
CheckInterval time.Duration `mapstructure:"checkInterval"`
}
BacklogDetectionConfig 通用积压检测配置(向后兼容)
type Cache ¶
type Cache struct {
Redis *RedisConnectOptions
Memory interface{}
}
func (Cache) Setup ¶
func (e Cache) Setup() (storage.AdapterCache, error)
Setup 构造cache 顺序 redis > 其他 > memory。cache 同处 best-effort 创建 subscriber (_redisSub),修复 casbin 跨实例 sub 历来 nil 的隐患:EnsureSubscriberClient 用惰性 newClient()、即便初始 Ping 不通也存 client,GetSubscriberClient() 恒非 nil, casbin PSubscribe 由 go-redis 自愈 + mux 退避重订阅接管;不影响 cache.Setup 成功。
type ClientMiddlewaresConfig ¶ added in v1.1.18
type ClientMiddlewaresConfig struct {
Trace bool `mapstructure:"trace" json:"trace,default=true"` // 链路跟踪
Duration bool `mapstructure:"duration" json:"duration,default=true"` // 持续时间统计
Prometheus bool `mapstructure:"prometheus" json:"prometheus,default=true"` // Prometheus监控
Breaker bool `mapstructure:"breaker" json:"breaker,default=true"` // 熔断器
}
ClientMiddlewaresConfig 客户端中间件配置
type Config ¶
type Config struct {
Application *Application `mapstructure:"application"`
HTTP *HTTPConfig `mapstructure:"http" json:"http"`
GRPC *GRPCConfig `mapstructure:"grpc" json:"grpc"`
Etcd *ETCDConfig `mapstructure:"etcd" json:"etcd"`
Logger *Logger `mapstructure:"logger"`
SSL *SSL `mapstructure:"ssl"`
JWT *JWTConfig `mapstructure:"jwt"`
Database *Database `mapstructure:"database"`
Cache *Cache `mapstructure:"cache"`
Queue *Queue `mapstructure:"queue"`
EventBus *EventBusConfig `mapstructure:"eventBus"`
Locker *Locker `mapstructure:"locker"`
Tenants *Tenants `mapstructure:"tenants"`
Storage *StorageConfig `mapstructure:"storage"` // 共享存储配置(HTTP/FTP)
DuplicateCheck *DuplicateCheckConfig `mapstructure:"duplicate_check"` // 共享去重配置
FTP *FTPConfig `mapstructure:"ftp"` // FTP 服务器配置
}
Config 顶层配置结构
type ConsumerConfig ¶ added in v1.1.19
type ConsumerConfig struct {
GroupID string `mapstructure:"groupId"` // 消费者组ID
AutoOffsetReset string `mapstructure:"autoOffsetReset"` // 偏移量重置策略 (earliest, latest, none)
SessionTimeout time.Duration `mapstructure:"sessionTimeout"` // 会话超时时间
HeartbeatInterval time.Duration `mapstructure:"heartbeatInterval"` // 心跳间隔
}
ConsumerConfig 消费者配置 - 用户配置层(简化) 只包含用户需要关心的核心配置字段
type Database ¶
type Database struct {
Driver string `mapstructure:"driver"`
Source string `mapstructure:"source"`
ConnMaxIdleTime int `mapstructure:"connmaxidletime"`
ConnMaxLifeTime int `mapstructure:"connmaxlifetime"`
MaxIdleConns int `mapstructure:"maxidleconns"`
MaxOpenConns int `mapstructure:"maxopenconns"`
Registers []Register `mapstructure:"registers"`
}
type DefaultTenantConfig ¶ added in v1.1.28
type DefaultTenantConfig struct {
// 服务级数据库配置映射(service_code -> config)
ServiceDatabases map[string]TenantDatabaseDetailConfig `mapstructure:"service_databases" yaml:"service_databases"` // 服务级数据库配置
Domain *TenantDomainConfig `mapstructure:"domain" yaml:"domain"` // 域名配置
FTPConfigs []TenantFTPDetailConfig `mapstructure:"ftp_configs" yaml:"ftp_configs"` // FTP 配置数组
Storage *TenantStorageDetailConfig `mapstructure:"storage" yaml:"storage"` // 存储配置
WvpConfig *TenantWvpDetailConfig `mapstructure:"wvp_config" yaml:"wvp_config"` // WVP 平台配置
}
DefaultTenantConfig 默认租户配置
func (*DefaultTenantConfig) GetActiveFTPConfigs ¶ added in v1.1.31
func (dtc *DefaultTenantConfig) GetActiveFTPConfigs() []TenantFTPDetailConfig
GetActiveFTPConfigs 获取所有状态为 active 的 FTP 配置
func (*DefaultTenantConfig) GetDefaultTenantDomain ¶ added in v1.1.28
func (dtc *DefaultTenantConfig) GetDefaultTenantDomain() *TenantDomainConfig
GetDefaultTenantDomain 获取默认租户域名配置
func (*DefaultTenantConfig) GetDefaultTenantStorage ¶ added in v1.1.28
func (dtc *DefaultTenantConfig) GetDefaultTenantStorage() *TenantStorageDetailConfig
GetDefaultTenantStorage 获取默认租户存储配置
func (*DefaultTenantConfig) GetFTPConfigByUsername ¶ added in v1.1.31
func (dtc *DefaultTenantConfig) GetFTPConfigByUsername(username string) *TenantFTPDetailConfig
GetFTPConfigByUsername 根据 Username 查找特定的 FTP 配置
func (*DefaultTenantConfig) GetFTPConfigs ¶ added in v1.1.31
func (dtc *DefaultTenantConfig) GetFTPConfigs() []TenantFTPDetailConfig
GetFTPConfigs 获取所有 FTP 配置数组
func (*DefaultTenantConfig) GetServiceDatabase ¶ added in v1.1.30
func (dtc *DefaultTenantConfig) GetServiceDatabase(serviceCode string) *TenantDatabaseDetailConfig
GetServiceDatabase 获取指定服务的数据库配置
func (*DefaultTenantConfig) GetServiceDatabases ¶ added in v1.1.30
func (dtc *DefaultTenantConfig) GetServiceDatabases() map[string]TenantDatabaseDetailConfig
GetServiceDatabases 获取服务级数据库配置映射
func (*DefaultTenantConfig) GetWvpConfig ¶ added in v1.1.48
func (dtc *DefaultTenantConfig) GetWvpConfig() *TenantWvpDetailConfig
GetWvpConfig 获取 WVP 平台配置
func (*DefaultTenantConfig) HasFTPConfigs ¶ added in v1.1.31
func (dtc *DefaultTenantConfig) HasFTPConfigs() bool
HasFTPConfigs 判断是否配置了多个 FTP
func (*DefaultTenantConfig) HasServiceDatabases ¶ added in v1.1.30
func (dtc *DefaultTenantConfig) HasServiceDatabases() bool
HasServiceDatabases 判断是否配置了服务级数据库
type DuplicateCheckConfig ¶ added in v1.1.26
type DuplicateCheckConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"` // 是否启用去重检查
Strategy string `mapstructure:"strategy" yaml:"strategy"` // 策略: filename, content, hybrid
Filename *DuplicateFilenameConfig `mapstructure:"filename" yaml:"filename"` // 文件名匹配配置
Content *DuplicateContentConfig `mapstructure:"content" yaml:"content"` // 内容匹配配置
}
DuplicateCheckConfig 去重检查配置(HTTP/FTP 共享)
func (*DuplicateCheckConfig) GetContentConfig ¶ added in v1.1.26
func (d *DuplicateCheckConfig) GetContentConfig() *DuplicateContentConfig
GetContentConfig 获取内容配置,带默认值
func (*DuplicateCheckConfig) GetFilenameConfig ¶ added in v1.1.26
func (d *DuplicateCheckConfig) GetFilenameConfig() *DuplicateFilenameConfig
GetFilenameConfig 获取文件名配置,带默认值
func (*DuplicateCheckConfig) GetStrategy ¶ added in v1.1.26
func (d *DuplicateCheckConfig) GetStrategy() string
GetStrategy 获取去重策略,默认为 filename
func (*DuplicateCheckConfig) IsEnabled ¶ added in v1.1.26
func (d *DuplicateCheckConfig) IsEnabled() bool
IsEnabled 检查是否启用去重检查
type DuplicateContentConfig ¶ added in v1.1.26
type DuplicateContentConfig struct {
Algorithm string `mapstructure:"algorithm" yaml:"algorithm"` // 哈希算法: sha1, sha256, md5
}
DuplicateContentConfig 内容去重配置
type DuplicateFilenameConfig ¶ added in v1.1.26
type DuplicateFilenameConfig struct {
CaseSensitive bool `mapstructure:"case_sensitive" yaml:"case_sensitive"` // 是否大小写敏感
MatchMode string `mapstructure:"match_mode" yaml:"match_mode"` // 匹配模式: prefix, exact, regex
}
DuplicateFilenameConfig 文件名去重配置
type ETCDConfig ¶ added in v1.1.18
type ETCDConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"` // 是否启用ETCD
Hosts []string `mapstructure:"hosts" json:"hosts"` // ETCD主机列表
Username string `mapstructure:"username" json:"username"` // 用户名
Password string `mapstructure:"password" json:"password"` // 密码
Namespace string `mapstructure:"namespace" json:"namespace"` // 命名空间前缀
DialTimeout int `mapstructure:"dialTimeout" json:"dialTimeout"` // 连接超时(秒)
Timeout int `mapstructure:"timeout" json:"timeout"` // 操作超时(秒)
TLS TLSConfig `mapstructure:"tls" json:"tls"` // TLS配置
Tenant *ETCDTenantConfig `mapstructure:"tenant" json:"tenant"` // 租户相关配置
}
ETCDConfig ETCD配置
func (*ETCDConfig) GetNamespacedKey ¶ added in v1.1.18
func (e *ETCDConfig) GetNamespacedKey(key string) string
GetNamespacedKey 获取带命名空间的键名
func (*ETCDConfig) IsEnabled ¶ added in v1.1.18
func (e *ETCDConfig) IsEnabled() bool
IsEnabled 检查etcd是否启用
type ETCDTenantConfig ¶ added in v1.1.27
type ETCDTenantConfig struct {
WatchEnabled bool `mapstructure:"watchEnabled" json:"watchEnabled"` // 启用 Watch 监听
WatchRetryInterval int `mapstructure:"watchRetryInterval" json:"watchRetryInterval"` // Watch 重试间隔(秒)
CacheFile string `mapstructure:"cacheFile" json:"cacheFile"` // 本地缓存文件路径
}
ETCDTenantConfig ETCD 租户数据提供者配置
func (*ETCDTenantConfig) GetCacheFile ¶ added in v1.1.27
func (c *ETCDTenantConfig) GetCacheFile() string
GetCacheFile 获取缓存文件路径
func (*ETCDTenantConfig) GetWatchRetryInterval ¶ added in v1.1.27
func (c *ETCDTenantConfig) GetWatchRetryInterval() int
GetWatchRetryInterval 获取 Watch 重试间隔
type ErrorHandlingConfig ¶ added in v1.1.19
type ErrorHandlingConfig struct {
DeadLetterTopic string `mapstructure:"deadLetterTopic"`
MaxRetryAttempts int `mapstructure:"maxRetryAttempts"`
RetryBackoffBase time.Duration `mapstructure:"retryBackoffBase"`
RetryBackoffMax time.Duration `mapstructure:"retryBackoffMax"`
}
ErrorHandlingConfig 错误处理配置
type EventBusConfig ¶ added in v1.1.3
type EventBusConfig struct {
// 基础配置
Type string `mapstructure:"type"` // kafka, nats, memory
ServiceName string `mapstructure:"serviceName"` // 微服务名称
// 统一特性配置(适用于所有EventBus类型)
HealthCheck HealthCheckConfig `mapstructure:"healthCheck"` // 健康检查
Monitoring MetricsConfig `mapstructure:"monitoring"` // 监控(复用现有的MetricsConfig)
Security SecurityConfig `mapstructure:"security"` // 安全
// 发布端配置
Publisher PublisherConfig `mapstructure:"publisher"`
// 订阅端配置
Subscriber SubscriberConfig `mapstructure:"subscriber"`
// 具体实现配置
Kafka KafkaConfig `mapstructure:"kafka"` // Kafka配置
NATS NATSConfig `mapstructure:"nats"` // NATS配置
Memory MemoryConfig `mapstructure:"memory"` // Memory配置
}
EventBusConfig 事件总线配置
func (*EventBusConfig) SetDefaults ¶ added in v1.1.19
func (c *EventBusConfig) SetDefaults()
SetDefaults 为EventBusConfig设置默认值
func (*EventBusConfig) Validate ¶ added in v1.1.19
func (c *EventBusConfig) Validate() error
Validate 验证EventBusConfig配置
type FTPConfig ¶ added in v1.1.26
type FTPConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
ListenAddr string `mapstructure:"listen_addr" yaml:"listen_addr"`
PublicHost string `mapstructure:"public_host" yaml:"public_host"`
PassivePortRange PortRange `mapstructure:"passive_port_range" yaml:"passive_port_range"`
IdleTimeout int `mapstructure:"idle_timeout" yaml:"idle_timeout"`
ConnectionTimeout int `mapstructure:"connection_timeout" yaml:"connection_timeout"`
TLS FTPTLSConfig `mapstructure:"tls" yaml:"tls"`
Users []FTPUserConfig `mapstructure:"users" yaml:"users"`
}
FTPConfig FTP 服务器配置
func (*FTPConfig) FindUser ¶ added in v1.1.26
func (f *FTPConfig) FindUser(username string) *FTPUserConfig
FindUser 根据用户名查找用户
func (*FTPConfig) GetConnectionTimeout ¶ added in v1.1.26
GetConnectionTimeout 获取连接超时时间(秒),有默认值
func (*FTPConfig) GetIdleTimeout ¶ added in v1.1.26
GetIdleTimeout 获取空闲超时时间(秒),有默认值
func (*FTPConfig) GetListenAddr ¶ added in v1.1.26
GetListenAddr 获取监听地址,有默认值
func (*FTPConfig) GetPassivePortEnd ¶ added in v1.1.26
GetPassivePortEnd 获取被动端口范围结束
func (*FTPConfig) GetPassivePortStart ¶ added in v1.1.26
GetPassivePortStart 获取被动端口范围起始
func (*FTPConfig) GetPublicHost ¶ added in v1.1.26
GetPublicHost 获取公共主机地址
func (*FTPConfig) GetTLSCertFile ¶ added in v1.1.26
GetTLSCertFile 获取 TLS 证书文件路径
func (*FTPConfig) GetTLSKeyFile ¶ added in v1.1.26
GetTLSKeyFile 获取 TLS 密钥文件路径
func (*FTPConfig) GetUsers ¶ added in v1.1.26
func (f *FTPConfig) GetUsers() []FTPUserConfig
GetUsers 获取静态用户列表
func (*FTPConfig) IsTLSEnabled ¶ added in v1.1.26
IsTLSEnabled 检查是否启用 TLS
type FTPResolverConfig ¶ added in v1.1.26
type FTPResolverConfig struct {
Type string `mapstructure:"type" yaml:"type"` // 识别方式: username, password
}
FTPResolverConfig FTP 租户识别配置
func (*FTPResolverConfig) GetType ¶ added in v1.1.28
func (frc *FTPResolverConfig) GetType() string
GetType 获取 FTP 租户识别方式
type FTPTLSConfig ¶ added in v1.1.26
type FTPTLSConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
CertFile string `mapstructure:"cert_file" yaml:"cert_file"`
KeyFile string `mapstructure:"key_file" yaml:"key_file"`
}
FTPTLSConfig FTP TLS 配置
type FTPUserConfig ¶ added in v1.1.26
type FTPUserConfig struct {
Username string `mapstructure:"username" yaml:"username"`
Password string `mapstructure:"password" yaml:"password"`
HomeDirectory string `mapstructure:"home_directory" yaml:"home_directory"`
WritePermission bool `mapstructure:"write_permission" yaml:"write_permission"`
}
FTPUserConfig FTP 静态用户配置(非多租户模式使用)
type GRPCClientConfig ¶ added in v1.1.18
type GRPCClientConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled,default=true"` // 是否启用gRPC客户端
ServiceKey string `mapstructure:"serviceKey" json:"serviceKey"` // 服务发现键名
Timeout int64 `mapstructure:"timeout" json:"timeout,default=2000"` // 超时时间(毫秒)
KeepaliveTime time.Duration `mapstructure:"keepaliveTime" json:"keepaliveTime,default=20s"` // Keepalive时间
// 连接配置
Endpoints []string `mapstructure:"endpoints" json:"endpoints,optional"` // 直连端点列表
Target string `mapstructure:"target" json:"target,optional"` // gRPC目标地址
NonBlock bool `mapstructure:"nonBlock" json:"nonBlock,optional"` // 非阻塞模式
UseDiscovery bool `mapstructure:"useDiscovery" json:"useDiscovery,default=true"` // 是否使用服务发现
// 认证配置
App string `mapstructure:"app" json:"app,optional"` // 应用名称
Token string `mapstructure:"token" json:"token,optional"` // 认证Token
// 性能配置
Retries int `mapstructure:"retries" json:"retries,default=3"` // 重试次数
MaxRecvMsgSize int `mapstructure:"maxRecvMsgSize" json:"maxRecvMsgSize,optional"` // 最大接收消息大小
MaxSendMsgSize int `mapstructure:"maxSendMsgSize" json:"maxSendMsgSize,optional"` // 最大发送消息大小
// 中间件配置
Middlewares ClientMiddlewaresConfig `mapstructure:"middlewares" json:"middlewares,optional"` // 中间件配置
}
GRPCClientConfig gRPC客户端配置
func (*GRPCClientConfig) ToGoZeroRpcClientConf ¶ added in v1.1.18
func (c *GRPCClientConfig) ToGoZeroRpcClientConf(etcdConfig *ETCDConfig) map[string]interface{}
ToGoZeroRpcClientConf 转换为go-zero的RpcClientConf
type GRPCConfig ¶ added in v1.1.18
type GRPCConfig struct {
Server GRPCServerConfig `mapstructure:"server" json:"server"` // gRPC服务配置
Client GRPCClientConfig `mapstructure:"client" json:"client"` // gRPC客户端配置
}
GRPCConfig gRPC服务配置
type GRPCServerConfig ¶ added in v1.1.18
type GRPCServerConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled,default=true"` // 是否启用gRPC服务
ListenOn string `mapstructure:"listenOn" json:"listenOn,default=:9000"` // 监听地址
ServiceKey string `mapstructure:"serviceKey" json:"serviceKey"` // 服务发现键名
Timeout int64 `mapstructure:"timeout" json:"timeout,default=2000"` // 超时时间(毫秒)
// 认证配置
Auth bool `mapstructure:"auth" json:"auth,optional"` // 是否启用认证
// 性能控制
CpuThreshold int64 `mapstructure:"cpuThreshold" json:"cpuThreshold,default=900,range=[0:1000]"` // CPU阈值
StrictControl bool `mapstructure:"strictControl" json:"strictControl,optional"` // 严格控制模式
MaxRecvMsgSize int `mapstructure:"maxRecvMsgSize" json:"maxRecvMsgSize,optional"` // 最大接收消息大小
MaxSendMsgSize int `mapstructure:"maxSendMsgSize" json:"maxSendMsgSize,optional"` // 最大发送消息大小
// TLS配置
TLS TLSConfig `mapstructure:"tls" json:"tls,optional"` // TLS配置
// KeepAlive配置
KeepAlive KeepAliveConfig `mapstructure:"keepAlive" json:"keepAlive,optional"` // 保活配置
// 中间件配置
Middlewares ServerMiddlewaresConfig `mapstructure:"middlewares" json:"middlewares,optional"` // 中间件配置
// 自定义服务配置
Services map[string]ServiceConfig `mapstructure:"services" json:"services,optional"` // 服务配置
}
GRPCServerConfig gRPC服务端配置
func (*GRPCServerConfig) ToGoZeroRpcServerConf ¶ added in v1.1.18
func (c *GRPCServerConfig) ToGoZeroRpcServerConf(etcdConfig *ETCDConfig) map[string]interface{}
ToGoZeroRpcServerConf 转换为go-zero的RpcServerConf
type HTTPConfig ¶ added in v1.1.10
type HTTPConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"` // 是否启用HTTP服务
Host string `mapstructure:"host" json:"host"` // 服务器绑定IP
Port int `mapstructure:"port" json:"port"` // HTTP端口
ReadTimeout int `mapstructure:"readtimeout" json:"readtimeout"` // 读取超时(秒)
WriteTimeout int `mapstructure:"writetimeout" json:"writetimeout"` // 写入超时(秒)
IdleTimeout int `mapstructure:"idletimeout" json:"idletimeout"` // 空闲超时(秒)
MaxHeaderBytes int `mapstructure:"maxheaderbytes" json:"maxheaderbytes"` // 最大请求头(MB)
SSL SSLConfig `mapstructure:"ssl" json:"ssl"` // SSL配置
}
HTTPConfig HTTP服务器配置(Gin)
type HTTPResolverConfig ¶ added in v1.1.26
type HTTPResolverConfig struct {
Type string `mapstructure:"type" yaml:"type"` // 识别方式: host, header, query, path
HeaderName string `mapstructure:"headerName" yaml:"headerName"` // 当 type 为 header 时使用的 header 名称
QueryParam string `mapstructure:"queryParam" yaml:"queryParam"` // 当 type 为 query 时使用的查询参数名
PathIndex int `mapstructure:"pathIndex" yaml:"pathIndex"` // 当 type 为 path 时使用的路径索引
HostMode string `mapstructure:"hostMode" yaml:"hostMode"` // 【新增】host 模式下的识别方式:numeric, domain, code
}
HTTPResolverConfig HTTP 租户识别配置
func (*HTTPResolverConfig) GetHeaderName ¶ added in v1.1.28
func (hrc *HTTPResolverConfig) GetHeaderName() string
GetHeaderName 获取 Header 名称(当 type 为 header 时使用)
func (*HTTPResolverConfig) GetHostModeOrDefault ¶ added in v1.1.45
func (hrc *HTTPResolverConfig) GetHostModeOrDefault() string
GetHostModeOrDefault 获取 host 模式,默认为 "numeric"
func (*HTTPResolverConfig) GetPathIndex ¶ added in v1.1.28
func (hrc *HTTPResolverConfig) GetPathIndex() int
GetPathIndex 获取路径索引(当 type 为 path 时使用)
func (*HTTPResolverConfig) GetQueryParam ¶ added in v1.1.28
func (hrc *HTTPResolverConfig) GetQueryParam() string
GetQueryParam 获取查询参数名(当 type 为 query 时使用)
func (*HTTPResolverConfig) GetType ¶ added in v1.1.28
func (hrc *HTTPResolverConfig) GetType() string
GetType 获取 HTTP 租户识别方式
type HealthCheckConfig ¶ added in v1.1.19
type HealthCheckConfig struct {
// 基础配置
Enabled bool `mapstructure:"enabled"` // 是否启用健康检查
// 发布器配置
Publisher HealthCheckPublisherConfig `mapstructure:"publisher"`
// 订阅监控器配置
Subscriber HealthCheckSubscriberConfig `mapstructure:"subscriber"`
}
HealthCheckConfig 统一健康检查配置
type HealthCheckPublisherConfig ¶ added in v1.1.19
type HealthCheckPublisherConfig struct {
Topic string `mapstructure:"topic"` // 健康检查发布主题(可选,默认自动生成)
Interval time.Duration `mapstructure:"interval"` // 发布间隔(默认2分钟)
Timeout time.Duration `mapstructure:"timeout"` // 发布超时(默认10秒)
FailureThreshold int `mapstructure:"failureThreshold"` // 连续失败阈值,触发重连(默认3次)
MessageTTL time.Duration `mapstructure:"messageTTL"` // 消息存活时间(默认5分钟)
}
HealthCheckPublisherConfig 健康检查发布器配置
type HealthCheckSubscriberConfig ¶ added in v1.1.19
type HealthCheckSubscriberConfig struct {
Topic string `mapstructure:"topic"` // 健康检查订阅主题(可选,默认自动生成)
MonitorInterval time.Duration `mapstructure:"monitorInterval"` // 监控检查间隔(默认30秒)
WarningThreshold int `mapstructure:"warningThreshold"` // 警告阈值(默认3次)
ErrorThreshold int `mapstructure:"errorThreshold"` // 错误阈值(默认5次)
CriticalThreshold int `mapstructure:"criticalThreshold"` // 严重阈值(默认10次)
}
HealthCheckSubscriberConfig 健康检查订阅监控器配置
type JWTConfig ¶ added in v1.1.10
type JWTConfig struct {
Secret string `mapstructure:"secret"`
Timeout int `mapstructure:"timeout"`
}
JWT JWT配置
type JetStreamConfig ¶ added in v1.1.19
type JetStreamConfig struct {
Enabled bool `mapstructure:"enabled"`
Domain string `mapstructure:"domain"`
APIPrefix string `mapstructure:"apiPrefix"`
PublishTimeout time.Duration `mapstructure:"publishTimeout"`
AckWait time.Duration `mapstructure:"ackWait"`
MaxDeliver int `mapstructure:"maxDeliver"`
// 流配置
Stream StreamConfig `mapstructure:"stream"`
// 消费者配置
Consumer NATSConsumerConfig `mapstructure:"consumer"`
}
JetStreamConfig JetStream配置
type KafkaConfig ¶ added in v1.1.3
type KafkaConfig struct {
Brokers []string `mapstructure:"brokers"` // Kafka集群地址
Producer ProducerConfig `mapstructure:"producer"` // 生产者配置
Consumer ConsumerConfig `mapstructure:"consumer"` // 消费者配置
}
KafkaConfig Kafka配置 - 用户配置层(简化) 只包含用户需要关心的核心配置字段
type KeepAliveConfig ¶ added in v1.1.10
type KeepAliveConfig struct {
Time int `mapstructure:"time" json:"time,default=7200"` // 保活时间(秒)
Timeout int `mapstructure:"timeout" json:"timeout,default=20"` // 保活超时(秒)
PermitWithoutStream bool `mapstructure:"permitWithoutStream" json:"permitWithoutStream,default=false"` // 允许无流保活
}
KeepAliveConfig gRPC KeepAlive配置
type Logger ¶
type Logger struct {
Type string `mapstructure:"type"` // zap,logrus,或自研,无用删除by jiyuanjje
Path string `mapstructure:"path"` // 日志文件路径
Level string `mapstructure:"level"` // 日志级别
Stdout bool `mapstructure:"stdout"` // 是否输出到标准控制台(true:输出,false:不输出)
MaxSize int `mapstructure:"maxsize"` // 每个日志文件最大多少MB,一般设置50MB add by jiyuanjje
ErrorMaxAge int `mapstructure:"errormaxage"` // error日志文件保留天数,一般设置14天 add by jiyuanjje
InfoMaxAge int `mapstructure:"infomaxage"` // info日志文件保留天数,一般设置3天 add by jiyuanjje
MaxBackups int `mapstructure:"maxbackups"` // 日志文件保留个数,一般设置20个 add by jiyuanjje
EnabledDB bool `mapstructure:"enableddb"` // 是否启用数据库日志(true:启用,false:不启用)
GormLoggerLevel int `mapstructure:"gormloggerlevel"` // 数据库日志打印级别(4:Info,3 Warn,2 Error,1 Silent)add by jiyuanjie
}
Logger 日志配置
type MemoryConfig ¶ added in v1.1.19
type MemoryConfig struct {
MaxChannelSize int `mapstructure:"maxChannelSize"` // 最大通道大小
BufferSize int `mapstructure:"bufferSize"` // 缓冲区大小
}
MemoryConfig Memory配置
type MetricsConfig ¶ added in v1.1.19
type MetricsConfig struct {
Enabled bool `mapstructure:"enabled"`
CollectInterval time.Duration `mapstructure:"collectInterval"`
ExportEndpoint string `mapstructure:"exportEndpoint"`
}
MetricsConfig 指标配置
type NATSConfig ¶ added in v1.1.19
type NATSConfig struct {
URLs []string `mapstructure:"urls"` // NATS服务器地址
ClientID string `mapstructure:"clientId"` // 客户端ID
MaxReconnects int `mapstructure:"maxReconnects"` // 最大重连次数
ReconnectWait time.Duration `mapstructure:"reconnectWait"` // 重连等待时间
ConnectionTimeout time.Duration `mapstructure:"connectionTimeout"` // 连接超时
JetStream JetStreamConfig `mapstructure:"jetstream"` // JetStream配置
Security NATSSecurityConfig `mapstructure:"security"` // NATS安全配置
}
NATSConfig NATS配置
type NATSConsumerConfig ¶ added in v1.1.19
type NATSConsumerConfig struct {
DurableName string `mapstructure:"durableName"`
DeliverPolicy string `mapstructure:"deliverPolicy"` // all, last, new, by_start_sequence, by_start_time
AckPolicy string `mapstructure:"ackPolicy"` // none, all, explicit
ReplayPolicy string `mapstructure:"replayPolicy"` // instant, original
MaxAckPending int `mapstructure:"maxAckPending"`
MaxWaiting int `mapstructure:"maxWaiting"`
MaxDeliver int `mapstructure:"maxDeliver"`
BackOff []time.Duration `mapstructure:"backOff"`
}
NATSConsumerConfig NATS消费者配置
type NATSSecurityConfig ¶ added in v1.1.19
type NATSSecurityConfig struct {
Enabled bool `mapstructure:"enabled"`
Token string `mapstructure:"token"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
NKeyFile string `mapstructure:"nkeyFile"`
CredFile string `mapstructure:"credFile"`
CertFile string `mapstructure:"certFile"`
KeyFile string `mapstructure:"keyFile"`
CAFile string `mapstructure:"caFile"`
SkipVerify bool `mapstructure:"skipVerify"`
}
NATSSecurityConfig NATS安全配置
type NSQOptions ¶
type NSQOptions struct {
DialTimeout time.Duration `opt:"dial_timeout" default:"1s"`
// Deadlines for network reads and writes
ReadTimeout time.Duration `opt:"read_timeout" min:"100ms" max:"5m" default:"60s"`
WriteTimeout time.Duration `opt:"write_timeout" min:"100ms" max:"5m" default:"1s"`
// Addresses is the local address to use when dialing an nsqd.
Addresses []string `opt:"addresses"`
// Duration between polling lookupd for new producers, and fractional jitter to add to
// the lookupd pool loop. this helps evenly distribute requests even if multiple consumers
// restart at the same time
//
// NOTE: when not using nsqlookupd, LookupdPollInterval represents the duration of time between
// reconnection attempts
LookupdPollInterval time.Duration `opt:"lookupd_poll_interval" min:"10ms" max:"5m" default:"60s"`
LookupdPollJitter float64 `opt:"lookupd_poll_jitter" min:"0" max:"1" default:"0.3"`
// Maximum duration when REQueueing (for doubling of deferred requeue)
MaxRequeueDelay time.Duration `opt:"max_requeue_delay" min:"0" max:"60m" default:"15m"`
DefaultRequeueDelay time.Duration `opt:"default_requeue_delay" min:"0" max:"60m" default:"90s"`
// Maximum amount of time to backoff when processing fails 0 == no backoff
MaxBackoffDuration time.Duration `opt:"max_backoff_duration" min:"0" max:"60m" default:"2m"`
// Unit of time for calculating consumer backoff
BackoffMultiplier time.Duration `opt:"backoff_multiplier" min:"0" max:"60m" default:"1s"`
// Maximum number of times this consumer will attempt to process a message before giving up
MaxAttempts uint16 `opt:"max_attempts" min:"0" max:"65535" default:"5"`
// Duration to wait for a message from an nsqd when in a state where RDY
// counts are re-distributed (e.g. max_in_flight < num_producers)
LowRdyIdleTimeout time.Duration `opt:"low_rdy_idle_timeout" min:"1s" max:"5m" default:"10s"`
// Duration to wait until redistributing RDY for an nsqd regardless of LowRdyIdleTimeout
LowRdyTimeout time.Duration `opt:"low_rdy_timeout" min:"1s" max:"5m" default:"30s"`
// Duration between redistributing max-in-flight to connections
RDYRedistributeInterval time.Duration `opt:"rdy_redistribute_interval" min:"1ms" max:"5s" default:"5s"`
// Identifiers sent to nsqd representing this client
// UserAgent is in the spirit of HTTP (default: "<client_library_name>/<version>")
ClientID string `opt:"client_id"` // (defaults: short hostname)
Hostname string `opt:"hostname"`
UserAgent string `opt:"user_agent"`
// Duration of time between heartbeats. This must be less than ReadTimeout
HeartbeatInterval time.Duration `opt:"heartbeat_interval" default:"30s"`
// Integer percentage to sample the channel (requires nsqd 0.2.25+)
SampleRate int32 `opt:"sample_rate" min:"0" max:"99"`
Tls *Tls `yaml:"tls" json:"tls"`
// Compression Settings
Deflate bool `opt:"deflate"`
DeflateLevel int `opt:"deflate_level" min:"1" max:"9" default:"6"`
Snappy bool `opt:"snappy"`
// Size of the buffer (in bytes) used by nsqd for buffering writes to this connection
OutputBufferSize int64 `opt:"output_buffer_size" default:"16384"`
// Timeout used by nsqd before flushing buffered writes (set to 0 to disable).
//
// WARNING: configuring clients with an extremely low
// (< 25ms) output_buffer_timeout has a significant effect
// on nsqd CPU usage (particularly with > 50 clients connected).
OutputBufferTimeout time.Duration `opt:"output_buffer_timeout" default:"250ms"`
// Maximum number of messages to allow in flight (concurrency knob)
MaxInFlight int `opt:"max_in_flight" min:"0" default:"1"`
// The server-side message timeout for messages delivered to this client
MsgTimeout time.Duration `opt:"msg_timeout" min:"0"`
// secret for nsqd authentication (requires nsqd 0.2.29+)
AuthSecret string `opt:"auth_secret"`
}
func (NSQOptions) GetNSQOptions ¶
func (e NSQOptions) GetNSQOptions() (*nsq.Config, error)
type PortRange ¶ added in v1.1.26
type PortRange struct {
Start int `mapstructure:"start" yaml:"start"`
End int `mapstructure:"end" yaml:"end"`
}
PortRange 端口范围配置
type ProducerConfig ¶ added in v1.1.19
type ProducerConfig struct {
RequiredAcks int `mapstructure:"requiredAcks"` // 消息确认级别 (0=不确认, 1=leader确认, -1=所有副本确认)
FlushFrequency time.Duration `mapstructure:"flushFrequency"` // 刷新频率
FlushMessages int `mapstructure:"flushMessages"` // 批量消息数
Timeout time.Duration `mapstructure:"timeout"` // 发送超时时间
}
ProducerConfig 生产者配置 - 用户配置层(简化) 只包含用户需要关心的核心配置字段 注意:压缩配置已从 Producer 级别移到 Topic 级别,通过 TopicBuilder 配置
type PublisherBacklogDetectionConfig ¶ added in v1.1.19
type PublisherBacklogDetectionConfig struct {
Enabled bool `mapstructure:"enabled"`
MaxQueueDepth int64 `mapstructure:"maxQueueDepth"` // 最大队列深度
MaxPublishLatency time.Duration `mapstructure:"maxPublishLatency"` // 最大发送延迟
RateThreshold float64 `mapstructure:"rateThreshold"` // 发送速率阈值 (msg/sec)
CheckInterval time.Duration `mapstructure:"checkInterval"` // 检测间隔
}
PublisherBacklogDetectionConfig 发送端积压检测配置
type PublisherConfig ¶ added in v1.1.19
type PublisherConfig struct {
// 重连配置
MaxReconnectAttempts int `mapstructure:"maxReconnectAttempts"` // 最大重连尝试次数(默认5次)
InitialBackoff time.Duration `mapstructure:"initialBackoff"` // 初始退避时间(默认1秒)
MaxBackoff time.Duration `mapstructure:"maxBackoff"` // 最大退避时间(默认30秒)
// 发布配置
PublishTimeout time.Duration `mapstructure:"publishTimeout"` // 发布超时(默认10秒)
// 企业特性
BacklogDetection PublisherBacklogDetectionConfig `mapstructure:"backlogDetection"` // 发送端积压检测
RateLimit RateLimitConfig `mapstructure:"rateLimit"` // 流量控制
ErrorHandling ErrorHandlingConfig `mapstructure:"errorHandling"` // 错误处理
}
PublisherConfig 发布端配置
type Queue ¶
type Queue struct {
Redis *QueueRedis `mapstructure:"redis"`
Memory *QueueMemory `mapstructure:"memory"`
NSQ *QueueNSQ `mapstructure:"nsq" json:"nsq"`
}
Queue 队列配置
type QueueMemory ¶
type QueueMemory struct {
PoolSize uint
}
type QueueNSQ ¶
type QueueNSQ struct {
NSQOptions // opt: tags — decoded by opt, not mapstructure; defer squash until NSQOptions gains mapstructure tags
ChannelPrefix string
}
type QueueRedis ¶
type QueueRedis struct {
RedisConnectOptions `mapstructure:",squash"`
Producer *queue.ProducerConfig
Consumer *queue.ConsumerConfig
}
type RateLimitConfig ¶ added in v1.1.19
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled"`
RatePerSecond float64 `mapstructure:"ratePerSecond"`
BurstSize int `mapstructure:"burstSize"`
}
RateLimitConfig 流量控制配置
type Redis ¶ added in v1.1.10
type Redis struct {
Addr string `mapstructure:"addr"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
}
Redis Redis配置
type RedisConnectOptions ¶
type RedisConnectOptions struct {
Network string `mapstructure:"network" json:"network"`
Addr string `mapstructure:"addr" json:"addr"`
Username string `mapstructure:"username" json:"username"`
Password string `mapstructure:"password" json:"password"`
DB int `mapstructure:"db" json:"db"`
PoolSize int `mapstructure:"pool_size" json:"pool_size"`
Tls *Tls `mapstructure:"tls" json:"tls"`
MaxRetries int `mapstructure:"max_retries" json:"max_retries"`
// Sentinel(可选)。MasterName 非空 => NewFailoverClient;空 => 保持单点行为。
MasterName string `mapstructure:"master_name" json:"master_name"`
SentinelAddrs []string `mapstructure:"sentinel_addrs" json:"sentinel_addrs"`
SentinelPassword string `mapstructure:"sentinel_password" json:"sentinel_password"`
}
func (RedisConnectOptions) GetRedisOptions ¶
func (e RedisConnectOptions) GetRedisOptions() (*redis.Options, error)
type RedisHealth ¶ added in v1.1.51
type RedisHealth struct {
// contains filtered or unexported fields
}
RedisHealth tracks the health status of the Redis connection.
type ResolverConfig ¶ added in v1.1.26
type ResolverConfig struct {
HTTP HTTPResolverConfig `mapstructure:"http" yaml:"http"` // HTTP 识别配置
FTP FTPResolverConfig `mapstructure:"ftp" yaml:"ftp"` // FTP 识别配置
}
ResolverConfig 租户识别配置(区分 HTTP 和 FTP)
func (*ResolverConfig) GetFTP ¶ added in v1.1.28
func (rc *ResolverConfig) GetFTP() *FTPResolverConfig
GetFTP 获取 FTP 租户识别配置
func (*ResolverConfig) GetHTTP ¶ added in v1.1.28
func (rc *ResolverConfig) GetHTTP() *HTTPResolverConfig
GetHTTP 获取 HTTP 租户识别配置
type SSLConfig ¶ added in v1.1.10
type SSLConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"` // 是否启用HTTPS
KeyStr string `mapstructure:"key_str"` // 私钥内容(字符串形式)
Pem string `mapstructure:"pem"` // 证书内容(PEM格式,字符串形式)
Domain string `mapstructure:"domain"` // 证书域名(用于生成证书)
}
SSLConfig SSL/TLS配置
type SecurityConfig ¶ added in v1.1.19
type SecurityConfig struct {
Enabled bool `mapstructure:"enabled"`
Protocol string `mapstructure:"protocol"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
CertFile string `mapstructure:"certFile"`
KeyFile string `mapstructure:"keyFile"`
CAFile string `mapstructure:"caFile"`
}
SecurityConfig 安全配置
type ServerMiddlewaresConfig ¶ added in v1.1.18
type ServerMiddlewaresConfig struct {
Trace bool `mapstructure:"trace" json:"trace,default=true"` // 链路跟踪
Recover bool `mapstructure:"recover" json:"recover,default=true"` // 异常恢复
Stat bool `mapstructure:"stat" json:"stat,default=true"` // 统计
Prometheus bool `mapstructure:"prometheus" json:"prometheus,default=true"` // Prometheus监控
Breaker bool `mapstructure:"breaker" json:"breaker,default=true"` // 熔断器
}
ServerMiddlewaresConfig 服务端中间件配置
type ServiceConfig ¶ added in v1.1.10
type ServiceConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled,default=true"` // 服务启用状态
Interceptors []string `mapstructure:"interceptors" json:"interceptors,optional"` // 拦截器列表
}
ServiceConfig 服务配置
type StorageConfig ¶ added in v1.1.26
type StorageConfig struct {
StorageSiteNo string `mapstructure:"storage_site_no" yaml:"storage_site_no"` // 标识当前部署/站点
PublicUrl string `mapstructure:"public_url" yaml:"public_url"` // 外部 HTTP URL 覆盖(如 "http://storage.jxt.com"),空则自动拼接
RootPath string `mapstructure:"root_path" yaml:"root_path"` // 根存储路径
TempPath string `mapstructure:"temp_path" yaml:"temp_path"` // 临时文件路径
}
StorageConfig 存储配置(HTTP/FTP 共享)
func (*StorageConfig) GetRootPath ¶ added in v1.1.26
func (s *StorageConfig) GetRootPath() string
GetRootPath 获取根存储路径,有默认值 这是 HTTP 和 FTP 共享的基础存储路径 FTP 上传会在此基础上加 /ftp 子目录
func (*StorageConfig) GetStorageSiteNo ¶ added in v1.1.26
func (s *StorageConfig) GetStorageSiteNo() string
GetStorageSiteNo 获取存储站点标识,有默认值
func (*StorageConfig) GetTempPath ¶ added in v1.1.26
func (s *StorageConfig) GetTempPath() string
GetTempPath 获取临时文件路径,有默认值
type StreamConfig ¶ added in v1.1.19
type StreamConfig struct {
Name string `mapstructure:"name"`
Subjects []string `mapstructure:"subjects"`
Retention string `mapstructure:"retention"` // limits, interest, workqueue
Storage string `mapstructure:"storage"` // file, memory
Replicas int `mapstructure:"replicas"`
MaxAge time.Duration `mapstructure:"maxAge"`
MaxBytes int64 `mapstructure:"maxBytes"`
MaxMsgs int64 `mapstructure:"maxMsgs"`
Discard string `mapstructure:"discard"` // old, new
}
StreamConfig 流配置
type SubscriberBacklogDetectionConfig ¶ added in v1.1.19
type SubscriberBacklogDetectionConfig struct {
Enabled bool `mapstructure:"enabled"`
MaxLagThreshold int64 `mapstructure:"maxLagThreshold"` // 最大消息积压数量
MaxTimeThreshold time.Duration `mapstructure:"maxTimeThreshold"` // 最大积压时间
CheckInterval time.Duration `mapstructure:"checkInterval"` // 检测间隔
}
SubscriberBacklogDetectionConfig 订阅端积压检测配置
type SubscriberConfig ¶ added in v1.1.19
type SubscriberConfig struct {
// 消费配置
MaxConcurrency int `mapstructure:"maxConcurrency"` // 最大并发数(默认10)
ProcessTimeout time.Duration `mapstructure:"processTimeout"` // 处理超时(默认30秒)
// 企业特性
BacklogDetection SubscriberBacklogDetectionConfig `mapstructure:"backlogDetection"` // 订阅端积压检测
RateLimit RateLimitConfig `mapstructure:"rateLimit"` // 流量控制
ErrorHandling ErrorHandlingConfig `mapstructure:"errorHandling"` // 错误处理
}
SubscriberConfig 订阅端配置
type TLSConfig ¶ added in v1.1.10
type TLSConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled,optional"` // 是否启用TLS
KeyStr string `mapstructure:"key_str" json:"key_str,optional"` // 私钥内容
Pem string `mapstructure:"pem" json:"pem,optional"` // 证书内容
Domain string `mapstructure:"domain" json:"domain,optional"` // 证书域名
}
TLSConfig TLS配置
type TenantDatabaseDetailConfig ¶ added in v1.1.28
type TenantDatabaseDetailConfig struct {
Driver string `mapstructure:"driver" yaml:"driver"` // 数据库驱动: postgres | mysql
Host string `mapstructure:"host" yaml:"host"` // 数据库主机
Port int `mapstructure:"port" yaml:"port"` // 数据库端口
Database string `mapstructure:"database" yaml:"database"` // 数据库名称
Username string `mapstructure:"username" yaml:"username"` // 数据库用户
Password string `mapstructure:"password" yaml:"password"` // 数据库密码
SSLMode string `mapstructure:"sslmode" yaml:"sslmode"` // SSL 模式: disable | require | verify-ca | verify-full
MaxOpenConns int `mapstructure:"max_open_conns" yaml:"max_open_conns"` // 最大打开连接数
MaxIdleConns int `mapstructure:"max_idle_conns" yaml:"max_idle_conns"` // 最大空闲连接数
ConnMaxIdleTime int `mapstructure:"conn_max_idle_time" yaml:"conn_max_idle_time"` // 连接最大空闲时间(秒)
ConnMaxLifeTime int `mapstructure:"conn_max_life_time" yaml:"conn_max_life_time"` // 连接最大生命周期(秒)
ConnectTimeout int `mapstructure:"connect_timeout" yaml:"connect_timeout"` // 连接超时(秒)
ReadTimeout int `mapstructure:"read_timeout" yaml:"read_timeout"` // 读超时(秒)
WriteTimeout int `mapstructure:"write_timeout" yaml:"write_timeout"` // 写超时(秒)
}
TenantDatabaseDetailConfig 详细的数据库配置
func (*TenantDatabaseDetailConfig) GetDatabaseConnMaxIdleTime ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnMaxIdleTime() int
GetDatabaseConnMaxIdleTime 获取连接最大空闲时间(秒)
func (*TenantDatabaseDetailConfig) GetDatabaseConnMaxLifeTime ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnMaxLifeTime() int
GetDatabaseConnMaxLifeTime 获取连接最大存活时间(秒)
func (*TenantDatabaseDetailConfig) GetDatabaseConnectTimeout ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnectTimeout() int
GetDatabaseConnectTimeout 获取连接超时(秒)
func (*TenantDatabaseDetailConfig) GetDatabaseConnectionString ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseConnectionString() string
func (*TenantDatabaseDetailConfig) GetDatabaseDriver ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseDriver() string
GetDatabaseDriver 获取数据库驱动
func (*TenantDatabaseDetailConfig) GetDatabaseHost ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseHost() string
GetDatabaseHost 获取数据库主机
func (*TenantDatabaseDetailConfig) GetDatabaseMaxIdleConns ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseMaxIdleConns() int
GetDatabaseMaxIdleConns 获取最大空闲连接数
func (*TenantDatabaseDetailConfig) GetDatabaseMaxOpenConns ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseMaxOpenConns() int
GetDatabaseMaxOpenConns 获取最大连接数
func (*TenantDatabaseDetailConfig) GetDatabaseName ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseName() string
GetDatabaseName 获取数据库名称
func (*TenantDatabaseDetailConfig) GetDatabasePassword ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabasePassword() string
GetDatabasePassword 获取数据库密码
func (*TenantDatabaseDetailConfig) GetDatabasePort ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabasePort() int
GetDatabasePort 获取数据库端口
func (*TenantDatabaseDetailConfig) GetDatabaseReadTimeout ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseReadTimeout() int
GetDatabaseReadTimeout 获取读超时(秒)
func (*TenantDatabaseDetailConfig) GetDatabaseSSLMode ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseSSLMode() string
GetDatabaseSSLMode 获取 SSL 模式
func (*TenantDatabaseDetailConfig) GetDatabaseUsername ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseUsername() string
GetDatabaseUsername 获取数据库用户名
func (*TenantDatabaseDetailConfig) GetDatabaseWriteTimeout ¶ added in v1.1.28
func (dbConfig *TenantDatabaseDetailConfig) GetDatabaseWriteTimeout() int
GetDatabaseWriteTimeout 获取写超时(秒)
type TenantDomainConfig ¶ added in v1.1.28
type TenantDomainConfig struct {
Primary string `mapstructure:"primary" yaml:"primary"` // 主域名(必填)
Aliases []string `mapstructure:"aliases" yaml:"aliases"` // 备用域名(可选)
Internal string `mapstructure:"internal" yaml:"internal"` // 内部调用域名(可选)
}
TenantDomainConfig 域名配置
func (*TenantDomainConfig) GetAliases ¶ added in v1.1.28
func (domainConfig *TenantDomainConfig) GetAliases() []string
GetAliases 获取域名别名列表
func (*TenantDomainConfig) GetAllDomainAliases ¶ added in v1.1.28
func (domainConfig *TenantDomainConfig) GetAllDomainAliases() []string
GetAllDomainAliases 获取所有域名别名(包括主域名)
func (*TenantDomainConfig) GetInternalDomain ¶ added in v1.1.28
func (domainConfig *TenantDomainConfig) GetInternalDomain() string
GetInternalDomain 获取内部调用域名
func (*TenantDomainConfig) GetPrimaryDomain ¶ added in v1.1.28
func (domainConfig *TenantDomainConfig) GetPrimaryDomain() string
GetPrimaryDomain 获取主域名
type TenantFTPDetailConfig ¶ added in v1.1.28
type TenantFTPDetailConfig struct {
Username string `mapstructure:"username" yaml:"username"` // FTP 用户名
InitialPassword string `mapstructure:"initial_password" yaml:"initial_password"` // 初始密码(首次创建时使用)
Description string `mapstructure:"description" yaml:"description"` // FTP 配置描述(用于标识不同 FTP)
Status string `mapstructure:"status" yaml:"status"` // 状态: active, inactive
}
TenantFTPDetailConfig 详细的 FTP 配置
func (*TenantFTPDetailConfig) GetFTPDescription ¶ added in v1.1.31
func (ftpConfig *TenantFTPDetailConfig) GetFTPDescription() string
GetFTPDescription 获取 FTP 配置描述
func (*TenantFTPDetailConfig) GetFTPInitialPassword ¶ added in v1.1.28
func (ftpConfig *TenantFTPDetailConfig) GetFTPInitialPassword() string
GetFTPInitialPassword 获取 FTP 初始密码
func (*TenantFTPDetailConfig) GetFTPStatus ¶ added in v1.1.31
func (ftpConfig *TenantFTPDetailConfig) GetFTPStatus() string
GetFTPStatus 获取 FTP 状态
func (*TenantFTPDetailConfig) GetFTPUsername ¶ added in v1.1.28
func (ftpConfig *TenantFTPDetailConfig) GetFTPUsername() string
GetFTPUsername 获取 FTP 用户名
func (*TenantFTPDetailConfig) IsFTPActive ¶ added in v1.1.31
func (ftpConfig *TenantFTPDetailConfig) IsFTPActive() bool
IsFTPActive 判断 FTP 配置是否处于 active 状态
type TenantStorageDetailConfig ¶ added in v1.1.28
type TenantStorageDetailConfig struct {
UploadQuotaGB int `mapstructure:"upload_quota_gb" yaml:"upload_quota_gb"` // 上传配额(GB)
MaxFileSizeMB int `mapstructure:"max_file_size_mb" yaml:"max_file_size_mb"` // 单文件最大大小(MB)
MaxConcurrentUploads int `mapstructure:"max_concurrent_uploads" yaml:"max_concurrent_uploads"` // 最大并发上传数
}
TenantStorageDetailConfig 详细的存储配置
func (*TenantStorageDetailConfig) GetStorageMaxConcurrentUploads ¶ added in v1.1.28
func (storageConfig *TenantStorageDetailConfig) GetStorageMaxConcurrentUploads() int
GetStorageMaxConcurrentUploads 获取最大并发上传数
func (*TenantStorageDetailConfig) GetStorageMaxFileSizeMB ¶ added in v1.1.28
func (storageConfig *TenantStorageDetailConfig) GetStorageMaxFileSizeMB() int
GetStorageMaxFileSizeMB 获取单文件最大大小(MB)
func (*TenantStorageDetailConfig) GetStorageUploadQuotaGB ¶ added in v1.1.28
func (storageConfig *TenantStorageDetailConfig) GetStorageUploadQuotaGB() int
GetStorageUploadQuotaGB 获取上传配额(GB)
type TenantWvpDetailConfig ¶ added in v1.1.48
type TenantWvpDetailConfig struct {
ApiUrl string `mapstructure:"api_url" yaml:"api_url"` // WVP HTTP API 地址
Realm string `mapstructure:"realm" yaml:"realm"` // SIP 域(用于 HA1 计算)
}
TenantWvpDetailConfig WVP 平台配置
type Tenants ¶ added in v1.1.11
type Tenants struct {
Resolver ResolverConfig `mapstructure:"resolver" yaml:"resolver"` // 租户识别配置
Storage *TenantsStorageConfig `mapstructure:"storage" yaml:"storage"` // 多租户存储配置
Default *DefaultTenantConfig `mapstructure:"default" yaml:"default"` // 默认租户配置
}
Tenants 统一的多租户配置
func (*Tenants) GetDefault ¶ added in v1.1.28
func (tc *Tenants) GetDefault() *DefaultTenantConfig
GetDefault 获取默认租户配置
func (*Tenants) GetDefaultTenantConfig ¶ added in v1.1.28
func (tc *Tenants) GetDefaultTenantConfig() *DefaultTenantConfig
GetDefaultTenantConfig 获取默认租户配置
func (*Tenants) GetResolver ¶ added in v1.1.28
func (tc *Tenants) GetResolver() *ResolverConfig
GetResolver 获取租户识别配置
func (*Tenants) GetTenantsStorageConfig ¶ added in v1.1.26
func (tc *Tenants) GetTenantsStorageConfig() *TenantsStorageConfig
GetTenantsStorageConfig 获取多租户存储配置
type TenantsStorageConfig ¶ added in v1.1.26
type TenantsStorageConfig struct {
Directory string `mapstructure:"directory" yaml:"directory"` // 租户存储目录名(默认: tenants)
}
TenantsStorageConfig 多租户存储配置
func (*TenantsStorageConfig) GetStorageDirectory ¶ added in v1.1.26
func (tc *TenantsStorageConfig) GetStorageDirectory() string
GetStorageDirectory 获取租户存储目录名,默认 "tenants"