config

package
v0.0.0-...-4b328e9 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("config")

Module provides config as fx module

Functions

func ProvideConfig

func ProvideConfig(path string) func() (*AppConfig, error)

ProvideConfig provides config with fx

Types

type AppConfig

type AppConfig struct {
	Server   ServerConfig   `yaml:"server"`
	Log      LogConfig      `yaml:"log"`
	Database DatabaseConfig `yaml:"database"`
	JWT      JWTConfig      `yaml:"jwt"`
}

func LoadFromFile

func LoadFromFile(path string) (*AppConfig, error)

LoadFromFile Load config from file path

func LoadFromReader

func LoadFromReader(reader io.Reader) (*AppConfig, error)

LoadFromReader load config from reader

type DatabaseConfig

type DatabaseConfig struct {
	Driver   string `yaml:"driver"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
	MaxIdle  int    `yaml:"max_idle"`
	MaxOpen  int    `yaml:"max_open"`
}

type JWTConfig

type JWTConfig struct {
	AccessSecret       string `yaml:"access_secret"`
	AccessTokenExpSec  int64  `yaml:"access_token_exp_sec"`
	RefreshSecret      string `yaml:"refresh_secret"`
	RefreshTokenExpSec int64  `yaml:"refresh_token_exp_sec"`
}

type LogConfig

type LogConfig struct {
	FileName    string `yaml:"file_name"`
	Level       string `yaml:"level"`
	MaxSize     int    `yaml:"max_size"`
	MaxBackups  int    `yaml:"max_backups"`
	MaxKeepDays int    `yaml:"max_keep_days"`
	Compress    bool   `yaml:"compress"`
}

type ServerConfig

type ServerConfig struct {
	BindPort         int32 `yaml:"bind_port"`
	GraceExitTimeout int   `yaml:"grace_exit_timeout"`
}

Jump to

Keyboard shortcuts

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