config

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VarPath  string = "var"
	LogPath         = VarPath + "/logs"
	TempPath        = VarPath + "/tmp"
)
View Source
const (
	FiveMB    int64 = 5 * 1024 * 1024   // 5MB
	TwentyMB  int64 = 20 * 1024 * 1024  // 20MB
	HundredMB int64 = 100 * 1024 * 1024 // 100MB
)

Variables

View Source
var AmsFileAllow = struct {
	Image      FileAllow
	Audio      FileAllow
	Video      FileAllow
	RewardFile FileAllow
}{
	Image:      FileAllow{AllowMimeType: []string{"png", "jpg", "jpeg", "gif", "bmp"}, AllowCapacitySize: FiveMB},
	Audio:      FileAllow{AllowMimeType: []string{"mp3", "wav", "flac", "mid", "mov", "m4a"}, AllowCapacitySize: TwentyMB},
	Video:      FileAllow{AllowMimeType: []string{"mp4", "mpg", "avi", "wmv", "mov", "flv", "rmvb", "3gp", "m4v", "mkv"}, AllowCapacitySize: HundredMB},
	RewardFile: FileAllow{AllowMimeType: []string{"xlsx", "xls"}, AllowCapacitySize: FiveMB},
}

AmsFileAllow 管理端上传限制

View Source
var AnonymousFileAllow = struct {
	File FileAllow
}{
	File: FileAllow{AllowMimeType: []string{"pdf", "doc", "docx", "ppt", "pptx", "xls", "xlsx"}, AllowCapacitySize: TwentyMB},
}

AnonymousFileAllow 匿名用户上传限制

View Source
var App *appConfig
View Source
var Cache *cache
View Source
var Database *database
View Source
var Etcd *etcd
View Source
var Filesystem *filesystem
View Source
var MessageQueue *messageQueue
View Source
var Monitor *monitor
View Source
var Redis *redis
View Source
var Server *serverConfig
View Source
var ThirdParty *thirdParty
View Source
var UserFileAllow = struct {
	Image FileAllow
	Audio FileAllow
	Video FileAllow
}{
	Image: FileAllow{AllowMimeType: []string{"png", "jpg", "jpeg", "gif"}, AllowCapacitySize: FiveMB},
	Audio: FileAllow{AllowMimeType: []string{"mp3", "wav", "flac", "mid", "mov", "m4a"}, AllowCapacitySize: TwentyMB},
	Video: FileAllow{AllowMimeType: []string{"mp4", "mpg", "avi", "wmv", "mov", "flv", "rmvb", "3gp", "m4v", "mkv"}, AllowCapacitySize: HundredMB},
}

UserFileAllow 终端用户上传限制

Functions

func Load

func Load()

Types

type ClusterConfig added in v0.3.0

type ClusterConfig struct {
	Addrs    []string `mapstructure:"addrs"`
	Password string   `mapstructure:"password"`
}

type Env

type Env string

Env 应用环境

const (
	// Prod 生产环境
	Prod Env = "prod"
	// Test 测试环境
	Test Env = "test"
	// Dev 开发环境
	Dev Env = "dev"
)

func (Env) String

func (e Env) String() string

func (Env) Valid

func (e Env) Valid() bool

type FileAllow

type FileAllow struct {
	// 允许上传的文件类型
	AllowMimeType []string
	// 允许上传的文件容量大小(单位:字节)
	AllowCapacitySize int64
}

type PoolConfig added in v0.3.0

type PoolConfig struct {
	MinIdleConns int `mapstructure:"min_idle_conns"`
	MaxRetries   int `mapstructure:"max_retries"`
	PoolSize     int `mapstructure:"pool_size"`
}

type RedisItem added in v0.3.0

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 SentinelConfig added in v0.3.0

type SentinelConfig struct {
	MasterName       string   `mapstructure:"master_name"`
	SentinelAddrs    []string `mapstructure:"sentinel_addrs"`
	Password         string   `mapstructure:"password"`
	SentinelPassword string   `mapstructure:"sentinel_password"`
	DB               int      `mapstructure:"db"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL