config

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogOutput *os.File // 日志文件

LogOutput 日志输出

Functions

func CloseLog

func CloseLog()

CloseLog 关闭日志

func Development

func Development()

Development 设定为开发环境

func OpenLog

func OpenLog()

OpenLog 打开日志

func Production

func Production()

Production 设定为生产环境

func ReloadLog

func ReloadLog()

ReloadLog 重新打开日志

Types

type Config

type Config struct {
	Mode    string `json:"mode,omitempty" env:"YAO_ENV" envDefault:"production"`    // 象传引擎启动模式 production/development
	Root    string `json:"root,omitempty" env:"YAO_ROOT" envDefault:"."`            // 应用根目录
	Host    string `json:"host,omitempty" env:"YAO_HOST" envDefault:"0.0.0.0"`      // 服务监听地址
	Port    int    `json:"port,omitempty" env:"YAO_PORT" envDefault:"5099"`         // 服务监听端口
	Cert    string `json:"cert,omitempty" env:"YAO_CERT"`                           // HTTPS 证书文件地址
	Key     string `json:"key,omitempty" env:"YAO_KEY"`                             // HTTPS 证书密钥地址
	Log     string `json:"log,omitempty" env:"YAO_LOG"`                             // 服务日志地址
	LogMode string `json:"log_mode,omitempty" env:"YAO_LOG_MODE" envDefault:"TEXT"` // 服务日志模式 JSON|TEXT
	// Session   string        `json:"session,omitempty" env:"YAO_SESSION" envDefault:"memory"`         // 用户会话模式 memory|redis|database
	JWTSecret string        `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"`                  // JWT 密钥
	DB        DBConfig      `json:"db,omitempty"`                                               // 数据库配置
	AllowFrom []string      `json:"allowfrom,omitempty" envSeparator:"|" env:"YAO_ALLOW_FROM" ` // Domain list the separator is |
	Session   SessionConfig `json:"session,omitempty"`
}

Config 象传应用引擎配置

var Conf Config

Conf 配置参数

func Load

func Load() Config

Load 加载配置

func LoadFrom

func LoadFrom(envfile string) Config

LoadFrom 从配置项中加载

type DBConfig

type DBConfig struct {
	Driver    string   `json:"driver,omitempty" env:"YAO_DB_DRIVER" envDefault:"sqlite3"`                        // 数据库驱动 sqlite3| mysql| postgres
	Primary   []string `json:"primary,omitempty" env:"YAO_DB_PRIMARY" envSeparator:"|" envDefault:"./db/yao.db"` // 主库连接DSN
	Secondary []string `json:"secondary,omitempty" env:"YAO_DB_SECONDARY" envSeparator:"|"`                      // 从库连接DSN
	AESKey    string   `json:"aeskey,omitempty" env:"YAO_DB_AESKEY"`                                             // 加密存储KEY
}

DBConfig 数据库配置

type SessionConfig

type SessionConfig struct {
	Store    string `json:"store,omitempty" env:"YAO_SESSION_STORE" envDefault:"file"`    // The session store. redis | file
	File     string `json:"file,omitempty" env:"YAO_SESSION_FILE"`                        // The file path
	Host     string `json:"host,omitempty" env:"YAO_SESSION_HOST" envDefault:"127.0.0.1"` // The redis host
	Port     string `json:"port,omitempty" env:"YAO_SESSION_PORT" envDefault:"6379"`      // The redis port
	Password string `json:"password,omitempty" env:"YAO_SESSION_PASSWORD"`                // The redis password
	Username string `json:"username,omitempty" env:"YAO_SESSION_USERNAME"`                // The redis username
	DB       string `json:"db,omitempty" env:"YAO_SESSION_DB" envDefault:"1"`             // The redis username
	IsCLI    bool   `json:"iscli,omitempty" env:"YAO_SESSION_ISCLI" envDefault:"false"`   // Command Line Start
}

SessionConfig 会话服务器

Jump to

Keyboard shortcuts

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