Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MainLogger *zap.Logger
Functions ¶
func InitLogger ¶
func InitLogger()
InitLogger function initializes the Logger engine using Zap as a base
func RecoverConfig ¶
func RecoverConfig(configPath string)
RecoverConfig function will recover Config File from the repo's root folder it could be JSON, YAML or TOML.
Types ¶
type Config ¶
type Config struct { // TMPFolder is a temporary folder to hold all app assets TMPFolder string `yaml:"tmpfolder" json:"tmpfolder"` // AppPort where the application will bind in AppPort int `yaml:"appport" json:"appport"` // SourceFile it's the file to load DDBB fixtures // you should use an absolutepath SourceFile string `yaml:"srcfile" json:"srcfile"` // DB realted config DB struct { // Host it's the address or hostname to connect with the DDBB // Relevant in all cases Host string `yaml:"host" json:"host"` // Type: DDBB type, for now just "redis" implemented // Relevant in all cases Type string `yaml:"type" json:"type"` // User Authentication for the DDBB (default: "") // Relevant for future implementations User string `yaml:"user" json:"user"` // Pass Authentication for the DDBB (default: "") // Relevant for future implementations Pass string `yaml:"pass" json:"pass"` // Port DDBB connection port (default: "") // Only relevant in MySQL and PostgreSQL Port int `yaml:"port" json:"port"` // Num DDDB number // Only relevant in Redis Num int `yaml:"num" json:"num"` } `yaml:"db" json:"db"` // Log related config Log struct { // Concanetated with TMPFolder LogPath string `yaml:"logpath" json:"logpath"` // Loglevel option can be these ones: debug|info|warn|error|panic|fatal. // For more info check gobserver/server/logger.go on the switch statement. // The log level are equivalent to zapcore.LevelEnabler type. // For more into check "go doc zapcore.LevelEnabler" or "go doc zapcore.DebugLevel" LogLevel string `yaml:"loglevel" json:"loglevel"` // LogTruncate put the Log file to 0 when it's openning it (flag os.O_TRUNC) LogTruncate bool `yaml:"logtruncate" json:"logtruncate"` } `yaml:"log" json:"log"` }
Config struct holds the fields for global config
var CFG Config
type JSONCfgFile ¶
type JSONCfgFile Config
func (*JSONCfgFile) Recover ¶
func (cfg *JSONCfgFile) Recover(configPath string) error
Recover function using the JSONCfgFile as a driver, parses the JSON file loaded and injects the content into a Config struct and exposes it in CFG global var
type Manage ¶
type Manage interface {
Recover() error
}
Manage interface gives the methods to cover different source files like YAML, TOML, JSON. First we create a new type from config to associate it to a method of Recover function, then develop the driver and put the logic on RecoverConfig function to select the correct type and driver.
type YAMLCfgFile ¶
type YAMLCfgFile Config
func (*YAMLCfgFile) Recover ¶
func (cfg *YAMLCfgFile) Recover(configPath string) error
Recover function using the YAMLCfgFile as a driver, parses the YAML file loaded and injects the content into a Config struct and exposes it in CFG global var