Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultConfigFile = "" DefaultListenHost = "17.0.0.1" DefaultListenPort = 9104 DefaultEnv = "prod" DefaultTokenExpire = 24 * 3600 DefaultQueryMySQLUser = "root" DefaultQueryMySQLPassword = "root" DefaultAdminMySQLUser = "root" DefaultAdminMySQLPassword = "root" DefaultForwardRequestDialTimeout = 10 DefaultForwardRequestResponseHeaderTimeout = 5 )
View Source
const ( DefaultExecMysqlExecTimeout = 30 // mysql默认执行超时时间 DefaultExecMysqlSelectLimit = 2000 // 默认执行select limit 值 DefaultExecCreateInsertSqlBatchSize = 1000 // 默认生成 批量insertsql值 )
View Source
const ( DefaultLogFilename = "./logs/easydb_api.log" DefaultLogMaxSize = 512 DefaultLogMaxBackups = 50 DefaultLogMaxAge = 7 DefaultLogCompress = false DefaultLogConsole = false DefaultLogLevel = "info" )
View Source
const ( DEBUG_LEVEL_STR = "debug" INFO_LEVEL_STR = "info" WARN_LEVEL_STR = "warn" ERROR_LEVEL_STR = "error" DPANIC_LEVEL_STR = "dpanic" PANIC_LEVEL_STR = "panic" FATAL_LEVEL_STR = "fatal" )
View Source
const ( DefaultMysqlHost = "127.0.0.1" DefaultMysqlPort = 3306 DefaultMysqlUsername = "easydb" DefaultMysqlPassword = "5c4b972f4e66929da2be30dec377d1ac0c81df4f5d1eaf57fbf0f67c70664ff309b6b40ca35781083305bb0d19dfb7f6" DefaultMysqlDatabase = "" DefaultMysqlConnTimeout = 5 DefaultMysqlCharset = "utf8mb4" DefaultMysqlMaxOpenConns = 1 DefaultMysqlMaxIdleConns = 1 DefaultMysqlAllowOldPasswords = 1 DefaultMysqlAutoCommit = true )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiConfig ¶
type ApiConfig struct { ConfigFile string `json:"config_file" toml:"config_file"` // 配置文件 ListenHost string `json:"listen_host" toml:"listen_host"` // api监听host ListenPort int64 `json:"listen_port" toml:"listen_port"` // api监听port Env string `json:"env" toml:"env"` // 环境 prod, dev TokenExpire int64 `json:"token_expire" toml:"token_expire"` // token过期时间单位s QueryMysqlUser string `json:"query_mysql_user" toml:"query_mysql_user"` // 查询数据库用户名 QueryMysqlPassword string `json:"query_mysql_password" toml:"query_mysql_password"` // 查询数据库管理员密码 AdminMysqlUser string `json:"admin_mysql_user" toml:"admin_mysql_user"` // 查询数据库用户名 AdminMysqlPassword string `json:"admin_mysql_password" toml:"admin_mysql_password"` // 查询数据库管理员密码 ForwardRequestDialTimeout int64 `json:"forward_request_dial_timeout" toml:"forward_request_dial_timeout"` // 请求转发链接超时时间 ForwardRequestResponseHeaderTimeout int64 `json:"forward_request_response_header_timeout" toml:"forward_request_response_header_timeout"` // 请求转发Response超时时间 }
type ExecConfig ¶
type ExecConfig struct { ExecMysqlExecTimeout int64 `json:"exec_mysql_exec_timeout" toml:"exec_mysql_exec_timeout"` ExecMysqlSelectLimit int64 `json:"exec_mysql_select_limit" toml:"exec_mysql_select_limit"` ExecCreateInsertSqlBatchSize int64 `json:"exec_create_insert_sql_batch_size" toml:"exec_create_insert_sql_batch_size"` }
func (*ExecConfig) DeepClone ¶
func (this *ExecConfig) DeepClone() (*ExecConfig, error)
type LogConfig ¶
type LogConfig struct { LogFilename string `json:"log_filename" toml:"log_filename"` // 日志文件 LogLevel string `json:"log_level" toml:"log_level"` // 日志级别 LogMaxSize int `json:"log_max_size" toml:"log_max_size"` // 文件最大大小(单位: M) LogMaxBackups int `json:"log_max_backups" toml:"log_max_backups"` // 日志文件最多保存多少个备份 LogMaxAge int `json:"log_max_age" toml:"log_max_age"` // 文件最多保存多少天 LogCompress bool `json:"log_compress" toml:"log_compress"` // 是否压缩 LogConsole bool `json:"log_console" toml:"log_console"` // 是否打印到控制台 }
func (*LogConfig) GetLogLevel ¶
func (*LogConfig) GetLogLevelZap ¶
type MysqlConfig ¶
type MysqlConfig struct { MysqlHost string `json:"mysql_host" toml:"mysql_host"` // 数据库host MysqlPort int64 `json:"mysql_port" toml:"mysql_port"` // 数据库端口 MysqlUsername string `json:"mysql_username" toml:"mysql_username"` // 数据库用户名 MysqlPassword string `json:"mysql_password" toml:"mysql_password"` // 数据库密码 MysqlDatabase string `json:"mysql_database" toml:"mysql_database"` // 链接数据库 MysqlConnTimeout int `json:"mysql_conn_timeout" toml:"mysql_conn_timeout"` // 数据库链接超时 MysqlCharset string `json:"mysql_charset" toml:"mysql_charset"` // 字符集 MysqlMaxOpenConns int `json:"mysql_max_open_conns" toml:"mysql_max_open_conns"` // 最大链接数 MysqlMaxIdleConns int `json:"mysql_max_idel_conns" toml:"mysql_max_idel_conns"` // 空闲链接数 MysqlAllowOldPasswords int `json:"mysql_allow_old_passwords" toml:"mysql_allow_old_passwords"` // 是否允许oldpassword MysqlAutoCommit bool `json:"mysql_auto_commit" toml:"mysql_auto_commit"` // 是否自动提交 }
func NewMysqlConfig ¶
func NewMysqlConfig(host string, port int64, username, password, database string) *MysqlConfig
func (*MysqlConfig) DeepClone ¶
func (this *MysqlConfig) DeepClone() (*MysqlConfig, error)
func (*MysqlConfig) GetDataSource ¶
func (this *MysqlConfig) GetDataSource() (string, error, error)
func (*MysqlConfig) GetFuzzyDataSource ¶
func (this *MysqlConfig) GetFuzzyDataSource() string
获取模糊数据源
func (*MysqlConfig) GetPassword ¶
func (this *MysqlConfig) GetPassword() (string, error)
type ServerConfig ¶
type ServerConfig struct { ApiConfig *ApiConfig `json:"api_config" toml:"api_config"` LogConfig *LogConfig `json:"log_config" toml:"log_config"` EasyQMysqlConfig *MysqlConfig `json:"easyq_mysql_config" toml:"easyq_mysql_config"` EasyDBMysqlConfig *MysqlConfig `json:"easydb_mysql_config" toml:"easydb_mysql_config"` ExecConfig *ExecConfig `json:"exec_config" toml:"exec_config"` }
func GetConfigs ¶
func GetConfigs(serverConfigCmd *ServerConfig, changeCmdKeys []string) (*ServerConfig, error)
配置生效优先级: 命令行 > toml > 默认
func GetConfigsFromToml ¶
func GetConfigsFromToml(filename string) (*ServerConfig, error)
func NewServerConfig ¶
func NewServerConfig( apiConfig *ApiConfig, logConfig *LogConfig, easyQMysqlConfig *MysqlConfig, easyDBMysqlConfig *MysqlConfig, execConfig *ExecConfig, ) *ServerConfig
func (*ServerConfig) DeepClone ¶
func (this *ServerConfig) DeepClone() (*ServerConfig, error)
Click to show internal directories.
Click to hide internal directories.