conf

package
v0.0.0-...-7261592 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// EnvProfileDir is the name of the environment variable for the search
	// directory of the profile
	EnvProfileDir = "PROJECT_CONFIG"

	// ProfileENV is the name of the profile directory in environment variable
	ProfileENV = EnvProfileDir
)

Functions

func Configure

func Configure(obj interface{}, file string, metaData ...interface{}) error

Configure .

func InitConfigurator

func InitConfigurator()

func IsDir

func IsDir(dir string) bool

IsDir accepts a string with a directory path and tests the path. It returns true if the path exists and it is a directory, and false otherwise.

func IsFile

func IsFile(path string) bool

IsFile accepts a string with a file path and tests the path. It returns true if the path exists and it is a file, and false otherwise.

func JoinPath

func JoinPath(elems ...string) string

JoinPath returns a string that joins any number of path elements into a single path, separating them with slashes.

func ProfileDirFromEnv

func ProfileDirFromEnv() string

ProfileDirFromEnv reads from environment variable with EnvProfileDir

func ReadConfigFile

func ReadConfigFile(obj interface{}, file string) error

func SetConfigurator

func SetConfigurator(c Configurator)

SetConfigurator assigns a Configurator to global configurator

Types

type Configuration

type Configuration struct {
	DB    *DBConf
	Redis *RedisConf
}

Configuration .

func GetConfiguration

func GetConfiguration() *Configuration

Get .

type Configurator

type Configurator interface {
	Configure(obj interface{}, file string, metaData ...interface{}) error
}

Configurator .

type DBConf

type DBConf struct {
	DSN             string `toml:"dsn"`
	MaxOpenConns    int    `toml:"max_open_conns"`
	MaxIdleConns    int    `toml:"max_idle_conns"`
	ConnMaxLifeTime int    `toml:"conn_max_life_time"`
}

DBConf .

type RedisConf

type RedisConf struct {
	Addr               string `toml:"addr"`
	Password           string `toml:"password"`
	DB                 int    `toml:"db"`
	MaxRetries         int    `toml:"max_retries"`
	PoolSize           int    `toml:"pool_size"`
	ReadTimeout        int    `toml:"read_timeout"`
	WriteTimeout       int    `toml:"write_timeout"`
	IdleTimeout        int    `toml:"idle_timeout"`
	IdleCheckFrequency int    `toml:"idle_check_frequency"`
	MaxConnAge         int    `toml:"max_conn_age"`
	PoolTimeout        int    `toml:"pool_timeout"`
}

RedisConf .

Jump to

Keyboard shortcuts

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