config

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DSLExtensions = []string{"*.yao", "*.json", "*.jsonc"}

DSLExtensions the dsl file Extensions

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

LogOutput 日志输出

Functions

func CloseLog

func CloseLog()

CloseLog 关闭日志

func Development

func Development()

Development 设定为开发环境

func Init added in v0.10.3

func Init()

Init setting

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"`            // The start mode production/development
	AppSource     string   `json:"app,omitempty"  env:"YAO_APP_SOURCE"`                             // The Application Source Root Path default same as Root
	Root          string   `json:"root,omitempty" env:"YAO_ROOT" envDefault:"."`                    // The Application Root Path
	Lang          string   `json:"lang,omitempty" env:"YAO_LANG" envDefault:"en-us"`                // Default language setting
	TimeZone      string   `json:"timezone,omitempty" env:"YAO_TIMEZONE"`                           // Default TimeZone
	DataRoot      string   `json:"data_root,omitempty" env:"YAO_DATA_ROOT" envDefault:""`           // The data root path
	ExtensionRoot string   `json:"extension_root,omitempty" env:"YAO_EXTENSION_ROOT" envDefault:""` // Plugin, Wasm root PATH, Default is <YAO_ROOT> (<YAO_ROOT>/plugins <YAO_ROOT>/wasms)
	Host          string   `json:"host,omitempty" env:"YAO_HOST" envDefault:"0.0.0.0"`              // The server host
	Port          int      `json:"port,omitempty" env:"YAO_PORT" envDefault:"5099"`                 // The server port
	Cert          string   `json:"cert,omitempty" env:"YAO_CERT"`                                   // The HTTPS certificate path
	Key           string   `json:"key,omitempty" env:"YAO_KEY"`                                     // The HTTPS certificate key path
	Log           string   `json:"log,omitempty" env:"YAO_LOG"`                                     // The log file path
	LogMode       string   `json:"log_mode,omitempty" env:"YAO_LOG_MODE" envDefault:"TEXT"`         // The log mode TEXT|JSON
	JWTSecret     string   `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"`                       // The JWT Secret
	DB            Database `json:"db,omitempty"`                                                    // The database config
	AllowFrom     []string `json:"allowfrom,omitempty" envSeparator:"|" env:"YAO_ALLOW_FROM"`       // Domain list the separator is |
	Session       Session  `json:"session,omitempty"`                                               // Session Config
	Studio        Studio   `json:"studio,omitempty"`                                                // Studio config
	Runtime       Runtime  `json:"runtime,omitempty"`                                               // Runtime config
}

Config 象传应用引擎配置

var Conf Config

Conf 配置参数

func Load

func Load() Config

Load the config

func LoadFrom

func LoadFrom(envfile string) Config

LoadFrom 从配置项中加载

type Database added in v0.10.3

type Database 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
}

Database 数据库配置

type Runtime added in v0.10.3

type Runtime struct {
	MinSize           int    `json:"minSize,omitempty" env:"YAO_RUNTIME_MIN" envDefault:"10"`                             // the number of V8 VM when runtime start. max value is 100, the default value is 2
	MaxSize           int    `json:"maxSize,omitempty" env:"YAO_RUNTIME_MAX" envDefault:"100"`                            // the maximum of V8 VM should be smaller than minSize, the default value is 10
	HeapSizeLimit     uint64 `json:"heapSizeLimit,omitempty" env:"YAO_RUNTIME_HEAP_LIMIT" envDefault:"1518338048"`        // the isolate heap size limit should be smaller than 1.5G, and the default value is 1518338048 (1.5G)
	HeapSizeRelease   uint64 `json:"heapSizeRelease,omitempty" env:"YAO_RUNTIME_HEAP_RELEASE" envDefault:"52428800"`      // the isolate will be re-created when reaching this value, and the default value is 52428800 (50M)
	HeapAvailableSize uint64 `json:"heapAvailableSize,omitempty" env:"YAO_RUNTIME_HEAP_AVAILABLE" envDefault:"524288000"` // the isolate will be re-created when the available size is smaller than this value, and the default value is 524288000 (500M)
	Precompile        bool   `json:"precompile,omitempty" env:"YAO_RUNTIME_PRECOMPILE" envDefault:"false"`                // if true compile scripts when the VM is created. this will increase the load time, but the script will run faster. the default value is false
}

Runtime Config

type Session added in v0.10.3

type Session 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
}

Session 会话服务器

type Studio added in v0.10.3

type Studio struct {
	Port   int    `json:"studio_port,omitempty" env:"YAO_STUDIO_PORT" envDefault:"5077"` // Studio port
	Secret string `json:"studio_secret,omitempty" env:"YAO_STUDIO_SECRET"`               // Studio Secret, if does not set, auto-generate a secret
	Auto   bool   `json:"-"`
}

Studio the studio config

Jump to

Keyboard shortcuts

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