init
This commit is contained in:
115
config/config.go
Normal file
115
config/config.go
Normal file
@ -0,0 +1,115 @@
|
||||
package config
|
||||
|
||||
var (
|
||||
SettingInfo = new(Setting)
|
||||
RPCServerSettingInfo = new(RPCServerSetting)
|
||||
SettingAreaInfo = make(map[string]map[string]string, 0)
|
||||
)
|
||||
|
||||
// Mysql 配置
|
||||
type Mysql struct {
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
DBName string `yaml:"db_name"`
|
||||
Parameters string `yaml:"parameters"`
|
||||
}
|
||||
|
||||
// Sqlite 配置
|
||||
type Sqlite struct {
|
||||
Path string `yaml:"path"`
|
||||
Name string `yaml:"name"`
|
||||
}
|
||||
|
||||
// RPCServer RPC Server服务
|
||||
type RPCServer struct {
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
IsTLS bool `yaml:"is_tls"`
|
||||
TLSName string `yaml:"tls_name"`
|
||||
Pem string `yaml:"pem"`
|
||||
Key string `yaml:"key"`
|
||||
}
|
||||
|
||||
// Redis 配置
|
||||
type Redis struct {
|
||||
Addr string `yaml:"addr"`
|
||||
Password string `yaml:"password"`
|
||||
DB int `yaml:"db"`
|
||||
MaxActive int `yaml:"max_active"`
|
||||
MaxIdle int `yaml:"max_idle"`
|
||||
IdleTimeout int `yaml:"idle_timeout"`
|
||||
}
|
||||
|
||||
// Setting 配置信息
|
||||
type Setting struct {
|
||||
Domain string `json:"domain" yaml:"domain"`
|
||||
Name string `yaml:"name"`
|
||||
TokenEffectTime int `yaml:"token_effect_time"`
|
||||
MultipleLogin bool `yaml:"multiple_login"`
|
||||
|
||||
// Server 配置
|
||||
Server struct {
|
||||
Port int `yaml:"port"`
|
||||
ReadTimeout int `yaml:"read_timeout"`
|
||||
WriteTimeout int `yaml:"write_timeout"`
|
||||
IdleTimeout int `yaml:"idle_timeout"`
|
||||
}
|
||||
|
||||
// Config 配置
|
||||
Config struct {
|
||||
VipPrice float64 `yaml:"vip_price"`
|
||||
Wechat struct {
|
||||
AppID string `json:"appid"`
|
||||
AppSecret string `yaml:"appsecret"`
|
||||
} `yaml:"wechat"`
|
||||
}
|
||||
|
||||
// Rate 限流器
|
||||
Rate struct {
|
||||
Limit int `yaml:"limit"`
|
||||
Capacity int `yaml:"capacity"`
|
||||
}
|
||||
|
||||
// Engine 配置
|
||||
Engine struct {
|
||||
Debug bool `yaml:"debug"`
|
||||
DBMode string `yaml:"db_mode"`
|
||||
MaxLifetime int `yaml:"max_lifetime"`
|
||||
MaxOpenConns int `yaml:"max_open_conns"`
|
||||
MaxIdleConns int `yaml:"max_idle_conns"`
|
||||
TablePrefix string `yaml:"table_prefix"`
|
||||
Complex bool `yaml:"complex"`
|
||||
Mysql *Mysql `yaml:"mysql"`
|
||||
Sqlite *Sqlite `yaml:"sqlite"`
|
||||
}
|
||||
|
||||
// Cache 缓存配置
|
||||
Cache struct {
|
||||
Type string `yaml:"type"`
|
||||
Redis *Redis `yaml:"redis"`
|
||||
}
|
||||
|
||||
// Upload 配置
|
||||
Upload struct {
|
||||
Path string `yaml:"path"`
|
||||
Ext string `yaml:"ext"`
|
||||
Exts []string `yaml:"-"`
|
||||
Size int64 `yaml:"size"`
|
||||
Rename bool `yaml:"rename"`
|
||||
}
|
||||
|
||||
// Log 配置
|
||||
Log struct {
|
||||
File string `yaml:"file"`
|
||||
LeastDay uint `yaml:"least_day"`
|
||||
Level string `yaml:"level"`
|
||||
}
|
||||
}
|
||||
|
||||
// RPCServerSetting 配置
|
||||
type RPCServerSetting struct {
|
||||
Key int `yaml:"key"`
|
||||
Servers map[string]*RPCServer `yaml:"servers"`
|
||||
}
|
42
config/const.go
Normal file
42
config/const.go
Normal file
@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
// Redis
|
||||
|
||||
const (
|
||||
RedisKeyForTaskQueue string = "task_queue"
|
||||
RedisKeyForTaskQueueBody string = "task_queue_body"
|
||||
|
||||
RedisKeyForAccount string = "account"
|
||||
RedisKeyForTenant string = "tenant:instance"
|
||||
RedisKeyForTenantKeys string = "tenant:keys"
|
||||
)
|
||||
|
||||
const (
|
||||
TokenForUID string = "uid"
|
||||
TokenForSession string = "session"
|
||||
TokenForGrade string = "grade"
|
||||
)
|
||||
|
||||
const (
|
||||
APIRequestToken string = "x-token"
|
||||
APIRequestGrade string = "x-grade"
|
||||
)
|
||||
|
||||
const (
|
||||
ContentForLocal string = "local"
|
||||
)
|
||||
|
||||
const (
|
||||
EventForRedisHashProduce string = "redis_hash_produce"
|
||||
EventForRedisHashDestroy string = "redis_hash_destroy"
|
||||
|
||||
EventForRedisListProduce string = "redis_list_produce"
|
||||
EventForRedisListDestroy string = "redis_list_destroy"
|
||||
|
||||
EventForAccountLoginProduce string = "account_login_produce"
|
||||
EventForSysLogProduce string = "sys_log_produce"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultChinaAreaCode string = "86"
|
||||
)
|
13
config/flag.go
Normal file
13
config/flag.go
Normal file
@ -0,0 +1,13 @@
|
||||
package config
|
||||
|
||||
import "flag"
|
||||
|
||||
var (
|
||||
Mode = flag.String("mode", "release", "Development Environment") // debug,test,release
|
||||
Version = flag.String("version", "v1.0", "IOT Version")
|
||||
)
|
||||
|
||||
// IsDebug 开发版本
|
||||
func IsDebug() bool {
|
||||
return *Mode == "debug"
|
||||
}
|
36
config/system.go
Normal file
36
config/system.go
Normal file
@ -0,0 +1,36 @@
|
||||
package config
|
||||
|
||||
var SystemConfig = map[string]interface{}{}
|
||||
|
||||
//png,jpg,csv,xls,xlsx,pcm,wav,amr,mp3,mp4,json
|
||||
|
||||
// 基本配置
|
||||
const (
|
||||
Name string = "name" // 名称
|
||||
Domain string = "domain" // 域名
|
||||
TokenEffectTime string = "token_effect_time" // Token有效时间
|
||||
MultipleLogin string = "multiple_login" // 是否开启多地登录
|
||||
)
|
||||
|
||||
const (
|
||||
ServePort string = "serve_port" // 服务器端口
|
||||
)
|
||||
|
||||
const (
|
||||
WechatForAppID string = "appid"
|
||||
)
|
||||
|
||||
const (
|
||||
EmailForAlias string = "email_alias" // 邮件别名
|
||||
EmailForHost string = "email_host" // 邮件Host
|
||||
EmailForPort string = "email_port" // 邮件端口地址
|
||||
EmailForUser string = "email_user" // 邮件用户
|
||||
EmailForPass string = "email_pass" // 邮件密码;定义邮箱服务器连接信息,如果是阿里邮箱 email_pass填密码,qq邮箱填授权码
|
||||
)
|
||||
|
||||
const (
|
||||
UploadPath string = "upload_path" // 上传路径
|
||||
UploadExt string = "upload_ext" // 上传文件限制
|
||||
UploadSize string = "upload_size" // 上传文件大小限制
|
||||
UploadRename string = "upload_rename" // 上传文件是否重命名
|
||||
)
|
Reference in New Issue
Block a user