GetRedisURL (config/redis.go)

lotus · go/event-ingestion/config/redis.go · go · MIT
database

Returns the Redis URL from Viper config, defaulting to docker or localhost.

// Source: https://github.com/uselotus/lotus | License: MIT | Copyright 2023 Lotus Tech Co
// Provided via justclaw.it.com; keep this notice with the code.
package config

import (
	"strings"

	"github.com/spf13/viper"
)

func GetRedisURL(v *viper.Viper) string {
	if v.GetString("redis_url") != "" {
		return v.GetString("redis_url")
	}

	dockerized := strings.ToLower(v.GetString("dockerized"))

	if !(dockerized == "false" || dockerized == "0" || dockerized == "no" || dockerized == "f" || dockerized == "") {
		return "redis://redis:6379"
	} else {
		return "redis://localhost:6379"
	}
}

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key