52 lines
1010 B
Go
52 lines
1010 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"gotemplate/api/queue"
|
|
"gotemplate/internal/database"
|
|
"gotemplate/internal/database/repository"
|
|
"gotemplate/internal/document"
|
|
"gotemplate/internal/env"
|
|
"gotemplate/internal/otel"
|
|
queueSVC "gotemplate/internal/queue"
|
|
"log"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/config"
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
|
|
closeTracer := otel.Init(ctx)
|
|
defer closeTracer()
|
|
|
|
database.RunMigrations()
|
|
|
|
cfg, err := config.LoadDefaultConfig(ctx)
|
|
if err != nil {
|
|
log.Fatalf("Unable to load SDK config: %v", err)
|
|
}
|
|
|
|
queueURL := env.GetFatal("QUEUE_URL")
|
|
|
|
sqsClient := sqs.NewFromConfig(cfg)
|
|
|
|
conn := database.GetDBConn(ctx)
|
|
db := repository.New(conn)
|
|
|
|
controllers := queue.Controllers{
|
|
Document: *queue.NewDocumentController(*document.New(ctx, db)),
|
|
}
|
|
|
|
config := queue.Queue{
|
|
Controllers: &controllers,
|
|
Config: &queueSVC.QueueConfig{
|
|
URL: queueURL,
|
|
Client: sqsClient,
|
|
},
|
|
}
|
|
|
|
queue.PollMessages(ctx, &config)
|
|
}
|