59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
"queryorchestration/api/queue"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/document"
|
|
"queryorchestration/internal/env"
|
|
"queryorchestration/internal/otel"
|
|
queueSVC "queryorchestration/internal/queue"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/config"
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
|
|
closeTracer := otel.Init(ctx)
|
|
defer closeTracer()
|
|
|
|
database.RunMigrations(os.Getenv("PWD"))
|
|
|
|
cfg, err := config.LoadDefaultConfig(ctx)
|
|
if err != nil {
|
|
log.Panicf("Unable to load SDK config: %v", err)
|
|
}
|
|
|
|
queueURL := env.GetPanic("QUEUE_URL")
|
|
|
|
sqsClient := sqs.NewFromConfig(cfg)
|
|
|
|
dbPool := database.GetDBPool(ctx)
|
|
dbQueries := repository.New(dbPool)
|
|
db := &database.Connection{
|
|
Pool: dbPool,
|
|
Queries: dbQueries,
|
|
}
|
|
valid := validator.New()
|
|
|
|
controllers := queue.Controllers{
|
|
Document: *queue.NewDocumentController(*document.New(db), valid),
|
|
}
|
|
|
|
config := queue.Queue{
|
|
Controllers: &controllers,
|
|
Config: &queueSVC.QueueConfig{
|
|
URL: queueURL,
|
|
Client: sqsClient,
|
|
},
|
|
}
|
|
|
|
queue.PollMessages(ctx, &config)
|
|
}
|