1
0

Better config handling with constants (#83)

This commit is contained in:
konrad
2019-07-06 20:12:26 +00:00
committed by Gitea
parent f1d21ea52b
commit 1f1a079fd3
17 changed files with 200 additions and 120 deletions

View File

@ -17,27 +17,27 @@
package red
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"github.com/go-redis/redis"
"github.com/spf13/viper"
)
var r *redis.Client
// InitRedis initializes a redis connection
func InitRedis() {
if !viper.GetBool("redis.enabled") {
if !config.RedisEnabled.GetBool() {
return
}
if viper.GetString("redis.host") == "" {
if config.RedisHost.GetString() == "" {
log.Log.Fatal("No redis host provided.")
}
r = redis.NewClient(&redis.Options{
Addr: viper.GetString("redis.host"),
Password: viper.GetString("redis.password"),
DB: viper.GetInt("redis.db"),
Addr: config.RedisHost.GetString(),
Password: config.RedisPassword.GetString(),
DB: config.RedisDB.GetInt(),
})
err := r.Ping().Err()