Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).

appview: config: add redis to config

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

authored by oppi.li and committed by

Tangled 27495db8 7a45c86c

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