putting in base query and collector framework
This commit is contained in:
+46
-46
@@ -1,46 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gotemplate/api/grpc/controllers"
|
||||
"gotemplate/api/grpc/spec"
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
"gotemplate/internal/name"
|
||||
"gotemplate/internal/otel"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
closeTracer := otel.Init(ctx)
|
||||
defer closeTracer()
|
||||
|
||||
database.RunMigrations()
|
||||
|
||||
host := "0.0.0.0"
|
||||
port := 8080
|
||||
address := net.JoinHostPort(host, strconv.Itoa(port))
|
||||
|
||||
lis, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
pool := database.GetDBPool(ctx)
|
||||
db := repository.New(pool)
|
||||
|
||||
grpcServer := grpc.NewServer()
|
||||
spec.RegisterNameServer(grpcServer, controllers.NewNameController(*name.New(ctx, db)))
|
||||
|
||||
log.Printf("Listening on port %d", port)
|
||||
if err := grpcServer.Serve(lis); err != nil {
|
||||
log.Fatalf("Failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gotemplate/api/grpc/controllers"
|
||||
"gotemplate/api/grpc/spec"
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
"gotemplate/internal/name"
|
||||
"gotemplate/internal/otel"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
closeTracer := otel.Init(ctx)
|
||||
defer closeTracer()
|
||||
|
||||
database.RunMigrations()
|
||||
|
||||
host := "0.0.0.0"
|
||||
port := 8080
|
||||
address := net.JoinHostPort(host, strconv.Itoa(port))
|
||||
|
||||
lis, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
pool := database.GetDBPool(ctx)
|
||||
db := repository.New(pool)
|
||||
|
||||
grpcServer := grpc.NewServer()
|
||||
spec.RegisterNameServer(grpcServer, controllers.NewNameController(*name.New(ctx, db)))
|
||||
|
||||
log.Printf("Listening on port %d", port)
|
||||
if err := grpcServer.Serve(lis); err != nil {
|
||||
log.Fatalf("Failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
+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