Files
oc-lib/config/conf.go

51 lines
1.1 KiB
Go
Raw Normal View History

2024-09-04 10:53:12 +02:00
package config
2024-07-16 10:56:36 +02:00
import "sync"
// ===================================================
// This class has to be updated everytime
// a new configuration variable is defined
// in a componant that imports oc-lib
// ===================================================
type Config struct {
2026-01-27 09:35:47 +01:00
NATSUrl string
MongoUrl string
MongoDatabase string
Host string
Port string
LokiUrl string
LogLevel string
Whitelist bool
PrivateKeyPath string
PublicKeyPath string
2024-07-18 14:11:13 +02:00
}
func (c Config) GetUrl() string {
2024-07-18 16:14:39 +02:00
return c.MongoUrl
2024-07-18 14:11:13 +02:00
}
func (c Config) GetDatabase() string {
2024-07-18 16:14:39 +02:00
return c.MongoDatabase
2024-07-16 10:56:36 +02:00
}
var instance *Config
var once sync.Once
func GetConfig() *Config {
once.Do(func() {
instance = &Config{}
})
return instance
}
2024-07-18 11:56:54 +02:00
2024-09-04 10:53:12 +02:00
func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string, logLevel string) *Config {
2024-09-04 14:21:01 +02:00
GetConfig().MongoUrl = mongoUrl
GetConfig().MongoDatabase = database
GetConfig().NATSUrl = natsUrl
GetConfig().LokiUrl = lokiUrl
GetConfig().LogLevel = logLevel
2024-11-28 11:05:54 +01:00
GetConfig().Whitelist = true
2024-09-04 14:21:01 +02:00
return GetConfig()
2024-07-18 11:56:54 +02:00
}