conf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string) interface{}

Get returns an interface

func GetAppID

func GetAppID() string

GetAppID get app id

func GetAppName

func GetAppName() string

GetAppName get app id

func GetAppVersion

func GetAppVersion() string

GetAppVersion get app version

func GetBool

func GetBool(key string) bool

GetBool returns the value associated with the key as a boolean

func GetConfigFile

func GetConfigFile() string

func GetDuration

func GetDuration(key string) time.Duration

GetDuration returns the value associated with the key as a time.Duration

func GetEnv

func GetEnv(key string) string

func GetFloat64

func GetFloat64(key string) float64

GetFloat64 returns the value associated with the key as a float64

func GetGrpcPort

func GetGrpcPort() int

GetGrpcPort get gRpc server port

func GetHttpPort

func GetHttpPort() int

GetHttpPort get http server port

func GetInt

func GetInt(key string) int

GetInt returns the value associated with the key as an integer

func GetInt32

func GetInt32(key string) int32

GetInt32 returns the value associated with the key as an integer

func GetInt64

func GetInt64(key string) int64

GetInt64 returns the value associated with the key as an integer

func GetLogLevel

func GetLogLevel() string

GetLogLevel get app id

func GetLogPath

func GetLogPath() string

GetLogPath get app id 路径统一强制结尾为 "/"

func GetMonitorPort

func GetMonitorPort() int

GetMonitorPort get gRpc server port

func GetMysqlLog

func GetMysqlLog() bool

GetMysqlLog get mysql log

func GetMysqlMaxIdleCons

func GetMysqlMaxIdleCons() int

GetMysqlMaxIdleCons get mysql max idle cons

func GetMysqlMaxIdleTime

func GetMysqlMaxIdleTime() int

GetMysqlMaxIdleTime get mysql max idle time

func GetMysqlMaxLife

func GetMysqlMaxLife() int

GetMysqlMaxLife get mysql max life

func GetMysqlPoolSize

func GetMysqlPoolSize() int

GetMysqlPoolSize get mysql pool size

func GetMysqlUrl

func GetMysqlUrl() string

GetMysqlUrl get mysql url

func GetString

func GetString(key string) string

GetString returns the value associated with the key as a string

func GetUint32

func GetUint32(key string) uint32

GetUint32 returns the value associated with the key as an integer

func IsProd

func IsProd() bool

func IsQa

func IsQa() bool

func Set

func Set(key string, value interface{})

Set sets the value for the key in the override register

func SetDefault

func SetDefault(key string, value interface{})

SetDefault sets the default value for this key

Types

type App

type App struct {
	AppId       string                 `yaml:"app_id"`
	AppName     string                 `yaml:"app_name"`
	AppVersion  string                 `yaml:"app_version"`
	Env         string                 `yaml:"env"`
	HttpPort    int32                  `yaml:"httpPort"`
	GrpcPort    int                    `yaml:"grpcPort"`
	MonitorPort int                    `yaml:"monitorPort"`
	Log         logCfg                 `yaml:"log"`
	Extra       map[string]interface{} `yaml:"extra"`
}

type Conf

type Conf struct {
	*viper.Viper
	// contains filtered or unexported fields
}

Conf represents the config struct

func New

func New(v *viper.Viper, opts ...Option) *Conf

New returns an initialized Conf instance

func NewDefault

func NewDefault() *Conf

NewDefault new default config Interface

func (*Conf) PreInitConfig

func (c *Conf) PreInitConfig()

PreInitConfig makes viper data declared in env and file available

type Interface

type Interface interface {
	InitConfig() error
	SetConfigFile(file string) Option
	GetConfigFile() string
	SetDefault(key string, value interface{})
	Set(key string, value interface{})
	Bind(v interface{}) error
	Get(key string) interface{}
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetUint32(key string) uint32
	GetInt32(key string) int32
	GetInt64(key string) int64
	GetFloat64(key string) float64
	GetDuration(key string) time.Duration
}

Interface represents the interface of config

type Option

type Option func(*Conf)

Option of config

func SetConfigFile

func SetConfigFile(file string) Option

SetConfigFile set file source config

Jump to

Keyboard shortcuts

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