forked from mirrors/pronouns.cc
feat(api): allow not having a redis connection for development
This commit is contained in:
parent
683d61bd82
commit
b9101e260b
1 changed files with 9 additions and 3 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/u1f320/pronouns.cc/backend/log"
|
||||
"emperror.dev/errors"
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
|
@ -33,10 +34,15 @@ func New() (*DB, error) {
|
|||
return nil, errors.Wrap(err, "creating postgres client")
|
||||
}
|
||||
|
||||
redis, err := (&radix.PoolConfig{}).New(context.Background(), "tcp", os.Getenv("REDIS"))
|
||||
var redis radix.Client
|
||||
if os.Getenv("REDIS") != "" {
|
||||
redis, err = (&radix.PoolConfig{}).New(context.Background(), "tcp", os.Getenv("REDIS"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "creating redis client")
|
||||
}
|
||||
} else {
|
||||
log.Warn("$REDIS was empty! ANY FUNCTIONALITY using redis will CRASH the server")
|
||||
}
|
||||
|
||||
minioClient, err := minio.New(os.Getenv("MINIO_ENDPOINT"), &minio.Options{
|
||||
Creds: credentials.NewStaticV4(os.Getenv("MINIO_ACCESS_KEY_ID"), os.Getenv("MINIO_ACCESS_KEY_SECRET"), ""),
|
||||
|
|
Loading…
Reference in a new issue