config

package
v0.0.0-...-32983dc Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvKeyReplacer = strings.NewReplacer(".", "_", "-", "_")

EnvKeyReplacer replace for environment variable parse

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Name        string     `mapstructure:"name"`
	Environment string     `mapstructure:"environment"`
	Port        string     `mapstructure:"port"`
	Auth        AuthConfig `mapstructure:"auth"`
}

type AuthConfig

type AuthConfig struct {
	AccessTokenType      string        `mapstructure:"access-token-type"`
	AccessTokenDuration  time.Duration `mapstructure:"access-token-duration"`
	RefreshTokenDuration time.Duration `mapstructure:"refresh-token-duration"`
	JWTPrivateKey        string        `mapstructure:"jwt-private-key"`
	PasetoSymmetricKey   string        `mapstructure:"paseto-symmetric-key"`
}

type CacheConfig

type CacheConfig struct {
	Redis RedisConfig `mapstructure:"redis"`
}

type Config

type Config struct {
	App   AppConfig   `mapstructure:"app"`
	Cache CacheConfig `mapstructure:"cache"`
	DB    DBConfig    `mapstructure:"db"`
	Log   LogConfig   `mapstructure:"log"`
	// contains filtered or unexported fields
}

func GetConfigEnvironment

func GetConfigEnvironment(profile Profile) (*Config, error)

GetConfigEnvironment read config from environment variables and config.toml file

func (*Config) AddCloser

func (c *Config) AddCloser(close func())

func (*Config) Close

func (c *Config) Close()

type DBConfig

type DBConfig struct {
	MySQL MySQLConfig `mapstructure:"mysql"`
}

type LogConfig

type LogConfig struct {
	Debug     bool   `mapstructure:"debug"`
	LogToFile bool   `mapstructure:"log-to-file"`
	Path      string `mapstructure:"path"`
}

type MySQLConfig

type MySQLConfig struct {
	Username           string `mapstructure:"username"`
	Password           string `mapstructure:"password"`
	Host               string `mapstructure:"host"`
	Port               string `mapstructure:"port"`
	DBName             string `mapstructure:"db-name"`
	MaxLifeInMinutes   int    `mapstructure:"max-life-in-minutes"`
	MaxIdleConnections int    `mapstructure:"max-idle-connections"`
	MaxOpenConnections int    `mapstructure:"max-open-connections"`
}

type Profile

type Profile string

Profile configuration profile

const (
	ProfileRun  Profile = "config"
	ProfileTest Profile = "config" // if you need a different file for test, you can create a different and change the name here
)

Profile default values

func (Profile) String

func (p Profile) String() string

type RedisConfig

type RedisConfig struct {
	Host              string        `mapstructure:"host"`
	Port              int           `mapstructure:"port"`
	DB                int           `mapstructure:"db"`
	Pass              string        `mapstructure:"pass"`
	Prefix            string        `mapstructure:"prefix"`
	DefaultExpiration time.Duration `mapstructure:"default-expiration"`
}

Jump to

Keyboard shortcuts

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