refactor: reuse constants for redis db
This commit is contained in:
@@ -27,13 +27,8 @@ import (
|
|||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// FIX: Use separate redis instance. We start with higher number because use this same instance in helios.
|
|
||||||
REDIS_DATABASE_FOR_AUTH int = 4
|
|
||||||
)
|
|
||||||
|
|
||||||
func redisForAuth() *redis.Client {
|
func redisForAuth() *redis.Client {
|
||||||
return internal.ConnectAndTestRedis(REDIS_DATABASE_FOR_AUTH)
|
return internal.ConnectAndTestRedis(db.RedisDBAuth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
redisDBAuth = 4 // shared with orion for session validation
|
|
||||||
redisDBPusher = 5 // dedicated to pusher state (presence, pub/sub)
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
port := utils.MustGetEnv("PORT")
|
port := utils.MustGetEnv("PORT")
|
||||||
grpcPort := utils.MustGetEnv("GRPC_PORT")
|
grpcPort := utils.MustGetEnv("GRPC_PORT")
|
||||||
@@ -35,10 +30,10 @@ func main() {
|
|||||||
defer db.Cleanup()
|
defer db.Cleanup()
|
||||||
|
|
||||||
// Redis for auth session validation (same DB as orion)
|
// Redis for auth session validation (same DB as orion)
|
||||||
authRedis := internal.ConnectAndTestRedis(redisDBAuth)
|
authRedis := internal.ConnectAndTestRedis(db.RedisDBAuth)
|
||||||
|
|
||||||
// Redis for pusher state (presence hashes, pub/sub)
|
// Redis for pusher state (presence hashes, pub/sub)
|
||||||
pusherRedis := internal.ConnectAndTestRedis(redisDBPusher)
|
pusherRedis := internal.ConnectAndTestRedis(db.RedisDBPusher)
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
authSvc := auth.NewAuthService(authRedis, nil) // nil aeroSvc — pusher only calls GetSession
|
authSvc := auth.NewAuthService(authRedis, nil) // nil aeroSvc — pusher only calls GetSession
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
// Shared database namespaces used across services
|
||||||
|
// FIX: Use separate redis instance. We start with higher number because use this same instance in helios.
|
||||||
|
const (
|
||||||
|
RedisDBAuth = 4 // auth sessions
|
||||||
|
RedisDBPusher = 5 // dedicated to pusher state (presence, pub/sub)
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user