config

package
v0.0.0-...-ddd43b2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright © 2020 Romber Li <romber2001@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2020 Romber Li <romber2001@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DefaultCommandName          = "das"
	DefaultDaemon               = false
	DefaultBaseDir              = constant.CurrentDir
	DefaultLogDir               = "./log"
	MinLogMaxSize               = 1
	MaxLogMaxSize               = constant.MaxInt
	MinLogMaxDays               = 1
	MaxLogMaxDays               = constant.MaxInt
	MinLogMaxBackups            = 1
	MaxLogMaxBackups            = constant.MaxInt
	DefaultServerAddr           = "0.0.0.0:6090"
	DefaultServerReadTimeout    = 5
	DefaultServerWriteTimeout   = 10
	MinServerReadTimeout        = 0
	MaxServerReadTimeout        = 60
	MinServerWriteTimeout       = 1
	MaxServerWriteTimeout       = 60
	DaemonArgTrue               = "--daemon=true"
	DaemonArgFalse              = "--daemon=false"
	DefaultDBName               = DefaultCommandName
	DefaultDBUser               = "root"
	DefaultDBPass               = "root"
	MinDBPoolMaxConnections     = 1
	MaxDBPoolMaxConnections     = constant.MaxInt
	MinDBPoolInitConnections    = 1
	MaxDBPoolInitConnections    = constant.MaxInt
	MinDBPoolMaxIdleConnections = 1
	MaxDBPoolMaxIdleConnections = constant.MaxInt
	MinDBPoolMaxIdleTime        = 1
	MaxDBPoolMaxIdleTime        = constant.MaxInt
	MinDBPoolKeepAliveInterval  = 1
	MaxDBPoolKeepAliveInterval  = constant.MaxInt
)

global constant

View Source
const (
	ConfKey                     = "config"
	DaemonKey                   = "daemon"
	LogFileKey                  = "log.file"
	LogLevelKey                 = "log.level"
	LogFormatKey                = "log.format"
	LogMaxSizeKey               = "log.maxSize"
	LogMaxDaysKey               = "log.maxDays"
	LogMaxBackupsKey            = "log.maxBackups"
	ServerAddrKey               = "server.addr"
	ServerPidFileKey            = "server.pidFile"
	ServerReadTimeoutKey        = "server.readTimeout"
	ServerWriteTimeoutKey       = "server.writeTimeout"
	DBMySQLAddrKey              = "db.mysql.addr"
	DBMySQLNameKey              = "db.mysql.name"
	DBMySQLUserKey              = "db.mysql.user"
	DBMySQLPassKey              = "db.mysql.pass"
	DBPoolMaxConnectionsKey     = "db.pool.maxConnections"
	DBPoolInitConnectionsKey    = "db.pool.initConnections"
	DBPoolMaxIdleConnectionsKey = "db.pool.maxIdleConnections"
	DBPoolMaxIdleTimeKey        = "db.pool.maxIdleTime"
	DBPoolKeepAliveIntervalKey  = "db.pool.keepAliveInterval"
)

configuration constant

Variables

View Source
var (
	ValidLogLevels = []string{"debug", "info", "warn", "warning", "error", "fatal"}
	ValidLogFormat = []string{"text", "json"}
)

Functions

func SetDefaultConfig

func SetDefaultConfig(baseDir string)

SetDefaultConfig set default configuration, it is the lowest priority

func TrimSpaceOfArg

func TrimSpaceOfArg(arg string) string

TrimSpaceOfArg trims spaces of given argument

func ValidateConfig

func ValidateConfig() (err error)

ValidateConfig validates if the configuration is valid

func ValidateDaemon

func ValidateDaemon() error

ValidateDaemon validates if daemon section is valid

func ValidateDatabase

func ValidateDatabase() error

func ValidateLog

func ValidateLog() error

ValidateLog validates if log section is valid.

func ValidateServer

func ValidateServer() error

ValidateServer validates if server section is valid

Types

This section is empty.

Jump to

Keyboard shortcuts

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