feat(api): allow not having a redis connection for development
This commit is contained in:
parent
683d61bd82
commit
b9101e260b
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"codeberg.org/u1f320/pronouns.cc/backend/log"
|
||||||
"emperror.dev/errors"
|
"emperror.dev/errors"
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/jackc/pgx/v4/pgxpool"
|
"github.com/jackc/pgx/v4/pgxpool"
|
||||||
|
@ -33,10 +34,15 @@ func New() (*DB, error) {
|
||||||
return nil, errors.Wrap(err, "creating postgres client")
|
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 {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "creating redis client")
|
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{
|
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"), ""),
|
Creds: credentials.NewStaticV4(os.Getenv("MINIO_ACCESS_KEY_ID"), os.Getenv("MINIO_ACCESS_KEY_SECRET"), ""),
|
||||||
|
|
Loading…
Reference in New Issue