chore: add qe and integrations with rabbit mq

This commit is contained in:
d3m0k1d
2026-04-29 14:26:59 +03:00
parent fe740da06b
commit d3a2fe0f9c
18 changed files with 1823 additions and 47 deletions
+33 -2
View File
@@ -1,12 +1,19 @@
package main
import (
"context"
"log"
"os"
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/docs"
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5/pgxpool"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/internal/handlers"
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/internal/mq"
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/internal/storage"
)
// @securityDefinitions.apikey Bearer
@@ -15,6 +22,31 @@ import (
// @description Type "Bearer" followed by a space and the JWT token.
func main() {
ctx := context.Background()
connStr := os.Getenv("DATABASE_URL")
if connStr == "" {
connStr = "postgres://postgres:postgres@localhost:5432/rostpoliplast?sslmode=disable"
}
pool, err := pgxpool.New(ctx, connStr)
if err != nil {
log.Fatalf("failed to connect to database: %v", err)
}
defer pool.Close()
if err := pool.Ping(ctx); err != nil {
log.Fatalf("failed to ping database: %v", err)
}
rabbit, err := mq.NewRabbitMQ()
if err != nil {
log.Printf("warning: failed to connect to rabbitmq: %v", err)
}
defer rabbit.Close()
repo := storage.NewRepository(pool)
h := &handlers.Handlers{Repo: repo, MQ: rabbit}
router := gin.Default()
v1 := router.Group("/api/v1")
@@ -24,8 +56,7 @@ func main() {
docs.SwaggerInfo.Version = "1.0"
docs.SwaggerInfo.Schemes = []string{"http", "https"}
baleHandlers := &handlers.Handlers{}
baleHandlers.RegisterRoutes(v1)
h.RegisterRoutes(v1)
{
v1.GET("/health", func(c *gin.Context) {