package main

import (
	"context"
	"github.com/jackc/pgx/v5/pgxpool"
	"sipro-mps/internal/config"
	"sipro-mps/internal/redis"
	"sipro-mps/internal/tasks/server"
)

func main() {
	cfg, err := config.LoadConfig()
	if err != nil {
		panic(err)
	}
	ctx := context.Background()
	err = redis.InitClient(ctx)
	if err != nil {
		panic(err)
	}
	defer redis.CloseClient()
	err = redis.InitLocker()
	if err != nil {
		panic(err)
	}
	defer redis.CloseLocker()
	dbpool, err := pgxpool.New(ctx, cfg.Database.URL)
	if err != nil {
		panic(err)
	}

	srv := server.NewAsynqServer(cfg.Redis, dbpool)
	srv.Run()
}
