putting in base query and collector framework
This commit is contained in:
+51
-50
@@ -1,50 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gotemplate/api/queue"
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
"gotemplate/internal/env"
|
||||
"gotemplate/internal/name"
|
||||
"gotemplate/internal/otel"
|
||||
"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.GetRequired("QUEUE_URL")
|
||||
|
||||
sqsClient := sqs.NewFromConfig(cfg)
|
||||
|
||||
conn := database.GetDBConn(ctx)
|
||||
db := repository.New(conn)
|
||||
|
||||
controllers := queue.Controllers{
|
||||
Name: *queue.NewNameController(*name.New(ctx, db)),
|
||||
}
|
||||
|
||||
config := queue.Queue{
|
||||
Controllers: &controllers,
|
||||
Config: &queue.QueueConfig{
|
||||
URL: queueURL,
|
||||
Client: sqsClient,
|
||||
},
|
||||
}
|
||||
|
||||
queue.PollMessages(ctx, &config)
|
||||
}
|
||||
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.GetRequired("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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user