config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBConnection

func NewDBConnection(conf YamlConfig) *gorm.DB

Types

type Admin

type Admin struct {
	Emails []string `yaml:"emails"`
}

type Application

type Application struct {
	Common Common `yaml:"Common"`
	Server Server `yaml:"Server"`
	Client Client `yaml:"Client"`
}

type BaseConfig

type BaseConfig struct {
	DBConnection *gorm.DB
	YamlConfig   YamlConfig
}

func NewBaseConfig

func NewBaseConfig() BaseConfig

func (*BaseConfig) ConnectDB

func (bc *BaseConfig) ConnectDB() error

ConnectDB: connect to MySQL only when needed (safe to call multiple times)

type Client

type Client struct {
	ServerEndpoint string `yaml:"ServerEndpoint"`
	UserEmail      string `yaml:"UserEmail"`
	UserPassword   string `yaml:"UserPassword"`
}

type Common

type Common struct {
}

type IntOrString

type IntOrString int

func (*IntOrString) UnmarshalYAML

func (ios *IntOrString) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML: receive number or string and convert to number. Non-numeric strings return 0 with warning log.

type MySQL

type MySQL struct {
	Host string `yaml:"host"`
	User string `yaml:"user"`
	Pass string `yaml:"pass"`
	Port string `yaml:"port"`
	Db   string `yaml:"db"`
}

type Redis

type Redis struct {
	Host string      `yaml:"host"`
	Port int         `yaml:"port"`
	User string      `yaml:"user"`
	Pass string      `yaml:"pass"`
	DB   IntOrString `yaml:"db"`
}

type Server

type Server struct {
	Admin     Admin  `yaml:"admin"`
	JWTSecret string `yaml:"jwt_secret"`
	LogLevel  string `yaml:"log_level"` // Added: debug / info / warn / error
}

type YamlConfig

type YamlConfig struct {
	Application Application `yaml:"Application"`
	MySQL       MySQL       `yaml:"MySQL"`
	Redis       Redis       `yaml:"Redis"`
}

Jump to

Keyboard shortcuts

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