chore: add ansible backend docker frontend-prep

This commit is contained in:
2026-01-21 13:05:13 +01:00
parent 5a280b6b01
commit 943fe4de7d
14930 changed files with 2341433 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
package db
import (
"context"
"gestion/models"
"log"
"os"
"github.com/redis/go-redis/v9"
)
var (
Redis *redis.Client
RedisCtx = context.Background()
)
type CommandWithDistance struct {
CommandID int
Address string
Lat float64
Lng float64
Distance float64
EstimatedETA int
QueueItem models.CommandQueue
}
const (
// Temps moyen estimé par livraison (en minutes)
AVG_DELIVERY_TIME = 15
// Nombre maximum de commandes par livreur
MAX_COMMANDS_PER_DELIVERYMAN = 10
)
// ============================================
// INITIALISATION DE REDIS
// ============================================
func InitRedis() {
host := getEnv("REDIS_HOST", "redis")
port := getEnv("REDIS_PORT", "6379")
password := os.Getenv("REDIS_PASSWORD")
addr := host + ":" + port
Redis = redis.NewClient(&redis.Options{
Addr: addr,
Password: password,
DB: 0,
})
_, err := Redis.Ping(RedisCtx).Result()
if err != nil {
log.Fatalf("❌ Erreur connexion Redis: %v", err)
}
log.Println("⚡ Redis connecté")
}