Documentation
¶
Index ¶
- Constants
- Variables
- type AppConfig
- type ByteSize
- type Cache
- type ClusterConfig
- type Config
- type DatabaseConfig
- type Etcd
- type EventConfig
- type FileAllow
- type GRPCConfig
- type HTTPConfig
- type HealthConfig
- type MessageQueue
- type Migration
- type Monitor
- type PoolConfig
- type Redis
- type RedisItem
- type Security
- type SentinelConfig
- type Server
- type Storage
- type ThirdParty
- type WebSocketConfig
Constants ¶
View Source
const ( Dev = "dev" Prod = "prod" Test = "test" Staging = "staging" )
应用环境
View Source
const ( VarPath string = "var" LogPath = VarPath + "/logs" TempPath = VarPath + "/tmp" )
Variables ¶
View Source
var AmsFileAllow = struct { Image FileAllow Audio FileAllow Video FileAllow Document FileAllow Compressed FileAllow }{ Image: FileAllow{AllowMimeType: []string{"png", "jpg", "jpeg", "gif", "bmp"}, AllowCapacitySize: 5 * MB}, Audio: FileAllow{AllowMimeType: []string{"mp3", "wav", "flac", "mid", "mov", "m4a"}, AllowCapacitySize: 20 * MB}, Video: FileAllow{AllowMimeType: []string{"mp4", "mpg", "avi", "wmv", "mov", "flv", "rmvb", "3gp", "m4v", "mkv"}, AllowCapacitySize: 2 * GB}, Document: FileAllow{AllowMimeType: []string{"pdf", "docx", "doc", "xlsx", "xls", "pptx", "ppt", "cvs", "txt", "markdown", "html"}, AllowCapacitySize: 50 * MB}, Compressed: FileAllow{AllowMimeType: []string{"zip", "rar", "tar", "tar.gz", "gz", "tgz", "tbz2", "tbz"}, AllowCapacitySize: 500 * MB}, }
AmsFileAllow 管理端上传限制
View Source
var AnonymousFileAllow = struct { File FileAllow }{ File: FileAllow{AllowMimeType: []string{"pdf", "doc", "docx", "ppt", "pptx", "xls", "xlsx"}, AllowCapacitySize: 20 * MB}, }
AnonymousFileAllow 匿名用户上传限制
View Source
var UserFileAllow = struct { Image FileAllow Audio FileAllow Video FileAllow }{ Image: FileAllow{AllowMimeType: []string{"png", "jpg", "jpeg", "gif"}, AllowCapacitySize: 5 * MB}, Audio: FileAllow{AllowMimeType: []string{"mp3", "wav", "flac", "mid", "mov", "m4a"}, AllowCapacitySize: 20 * MB}, Video: FileAllow{AllowMimeType: []string{"mp4", "mpg", "avi", "wmv", "mov", "flv", "rmvb", "3gp", "m4v", "mkv"}, AllowCapacitySize: 100 * MB}, }
UserFileAllow 终端用户上传限制
Functions ¶
This section is empty.
Types ¶
type AppConfig ¶
type AppConfig struct {
Name string `mapstructure:"name"`
Environment string `mapstructure:"environment"`
Debug bool `mapstructure:"debug"`
Domain string `mapstructure:"domain"`
}
AppConfig 应用基本配置
type Cache ¶
type Cache struct {
Driver string `mapstructure:"driver"`
Serializer string `mapstructure:"serializer"`
}
Cache 应用缓存
type ClusterConfig ¶
type Config ¶
type Config struct {
App AppConfig `mapstructure:"app"`
Server Server `mapstructure:"server"`
Security Security `mapstructure:"security"`
Database DatabaseConfig `mapstructure:"database"`
Redis Redis `mapstructure:"redis"`
Cache Cache `mapstructure:"cache"`
MessageQueue MessageQueue `mapstructure:"message_queue"`
Etcd Etcd `mapstructure:"etcd"`
Storage Storage `mapstructure:"storage"`
Monitor Monitor `mapstructure:"monitor"`
ThirdParty ThirdParty `mapstructure:"third_party"`
}
Config 应用配置
var GlobalConfig *Config
type DatabaseConfig ¶
type DatabaseConfig struct {
Migration Migration `mapstructure:"migration"`
Driver string `mapstructure:"driver"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Database string `mapstructure:"database"`
MaxOpenConns int `mapstructure:"max_open_conns"`
MaxIdleConns int `mapstructure:"max_idle_conns"`
ConnMaxLifetime time.Duration `mapstructure:"conn_max_lifetime"`
}
DatabaseConfig 数据库配置
type EventConfig ¶
type EventConfig struct {
Enabled bool `mapstructure:"enabled"`
Driver string `mapstructure:"driver"`
}
EventConfig 事件消费者服务配置
type GRPCConfig ¶
type GRPCConfig struct {
Enabled bool `mapstructure:"enabled"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Namespace string `mapstructure:"namespace"`
}
GRPCConfig gRPC配置
type HTTPConfig ¶
type HTTPConfig struct {
Enabled bool `mapstructure:"enabled"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
}
HTTPConfig HTTP服务配置
type HealthConfig ¶
type MessageQueue ¶
type MessageQueue struct {
Enabled bool `mapstructure:"enabled"`
Driver string `mapstructure:"driver"`
Amqp amqp `mapstructure:"amqp"`
}
MessageQueue 消息队列配置
type Monitor ¶
type Monitor struct {
ServiceName string `mapstructure:"service_name"`
ServiceVersion string `mapstructure:"service_version"`
Tracer otlp `mapstructure:"tracer"`
Metrics otlp `mapstructure:"metrics"`
Log otlp `mapstructure:"log"`
}
Monitor 平台监控配置
type PoolConfig ¶
type Redis ¶
type Redis struct {
Main RedisItem `mapstructure:"main"`
Cache RedisItem `mapstructure:"cache"`
MQ RedisItem `mapstructure:"mq"`
}
Redis redis配置
type RedisItem ¶
type RedisItem struct {
// 单机模式配置
Host string `mapstructure:"host"`
Port string `mapstructure:"port"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
KeyPrefix string `mapstructure:"key_prefix"`
// 模式选择: standalone, cluster, sentinel
Mode string `mapstructure:"mode"`
// 集群模式配置
Cluster ClusterConfig `mapstructure:"cluster"`
// 哨兵模式配置
Sentinel SentinelConfig `mapstructure:"sentinel"`
// 连接池配置
Pool PoolConfig `mapstructure:"pool"`
}
type Security ¶
type Security struct {
JWT struct {
Secret string `mapstructure:"secret"`
} `mapstructure:"jwt"`
}
Security 安全配置
type SentinelConfig ¶
type Server ¶
type Server struct {
HTTP HTTPConfig `mapstructure:"http"`
GRPC GRPCConfig `mapstructure:"grpc"`
WebSocket WebSocketConfig `mapstructure:"websocket"`
Event EventConfig `mapstructure:"event"`
Health HealthConfig `mapstructure:"health"`
}
Server 服务配置
type Storage ¶
type Storage struct {
Driver string `mapstructure:"driver"`
CdnDomain string `mapstructure:"cdn_domain"`
Local local `mapstructure:"local"`
MinIO cloudStorage `mapstructure:"minio"`
AliOss cloudStorage `mapstructure:"ali_oss"`
HwObs cloudStorage `mapstructure:"hw_obs"`
TxCos cloudStorage `mapstructure:"tx_cos"`
S3 cloudStorage `mapstructure:"s3"`
}
type ThirdParty ¶
type ThirdParty struct {
Wx wx `mapstructure:"wx"`
TTS tts `mapstructure:"tts"`
}
ThirdParty 第三方服务
type WebSocketConfig ¶
type WebSocketConfig struct {
Enabled bool `mapstructure:"enabled"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
}
WebSocketConfig WebSocket配置
Click to show internal directories.
Click to hide internal directories.