forked from tangled.org/core
this repo has no description

appview: config: add redis to config


Signed-off-by: oppiliappan <me@oppi.li>

Changed files
+23
appview
+23
appview/config.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "fmt" 6 + "net/url" 5 7 6 8 "github.com/sethvargo/go-envconfig" 7 9 ) ··· 41 43 Endpoint string `env:"ENDPOINT, default=https://eu.i.posthog.com"` 42 44 } 43 45 46 + type RedisConfig struct { 47 + Addr string `env:"ADDR, default=localhost:6379"` 48 + Password string `env:"PASS"` 49 + DB int `env:"DB, default=0"` 50 + } 51 + 52 + func (cfg RedisConfig) ToURL() string { 53 + u := &url.URL{ 54 + Scheme: "redis", 55 + Host: cfg.Addr, 56 + Path: fmt.Sprintf("/%d", cfg.DB), 57 + } 58 + 59 + if cfg.Password != "" { 60 + u.User = url.UserPassword("", cfg.Password) 61 + } 62 + 63 + return u.String() 64 + } 65 + 44 66 type Config struct { 45 67 Core CoreConfig `env:",prefix=TANGLED_"` 46 68 Jetstream JetstreamConfig `env:",prefix=TANGLED_JETSTREAM_"` ··· 49 71 Camo CamoConfig `env:",prefix=TANGLED_CAMO_"` 50 72 Avatar AvatarConfig `env:",prefix=TANGLED_AVATAR_"` 51 73 OAuth OAuthConfig `env:",prefix=TANGLED_OAUTH_"` 74 + Redis RedisConfig `env:",prefix=TANGLED_REDIS_"` 52 75 } 53 76 54 77 func LoadConfig(ctx context.Context) (*Config, error) {