2019-10-05 21:53:22 +05:00
|
|
|
package configuration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/rs/zerolog"
|
2021-11-20 23:06:40 +05:00
|
|
|
"go.dev.pztrn.name/giredore/internal/logger"
|
2019-10-05 21:53:22 +05:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-10-07 21:51:45 +05:00
|
|
|
log zerolog.Logger
|
2019-10-05 21:53:22 +05:00
|
|
|
|
2019-10-07 18:21:26 +05:00
|
|
|
envCfg *envConfig
|
|
|
|
Cfg *fileConfig
|
2019-10-05 21:53:22 +05:00
|
|
|
)
|
|
|
|
|
|
|
|
func Initialize() {
|
|
|
|
log = logger.Logger.With().Str("type", "internal").Str("package", "configuration").Logger()
|
|
|
|
log.Info().Msg("Initializing...")
|
|
|
|
|
2022-06-29 15:04:57 +05:00
|
|
|
// nolint:exhaustruct
|
2019-10-07 18:21:26 +05:00
|
|
|
envCfg = &envConfig{}
|
|
|
|
envCfg.Initialize()
|
|
|
|
|
2022-06-29 15:04:57 +05:00
|
|
|
// nolint:exhaustruct
|
2019-10-07 18:21:26 +05:00
|
|
|
Cfg = &fileConfig{}
|
2019-10-05 21:53:22 +05:00
|
|
|
Cfg.Initialize()
|
2019-10-07 18:21:26 +05:00
|
|
|
|
|
|
|
Cfg.HTTP.Listen = envCfg.HTTP.Listen
|
|
|
|
Cfg.HTTP.WaitForSeconds = envCfg.HTTP.WaitForSeconds
|
|
|
|
}
|
|
|
|
|
|
|
|
func Shutdown() {
|
|
|
|
Cfg.Save()
|
2019-10-05 21:53:22 +05:00
|
|
|
}
|