moveservicesInterfaces

This commit is contained in:
Michael McGuinness
2025-01-07 13:01:14 +00:00
parent ccb1234911
commit 56b447dfcf
20 changed files with 302 additions and 1460 deletions
+53
View File
@@ -0,0 +1,53 @@
package main
import (
"context"
"log"
"net"
"os"
"queryorchestration/api/controllers"
serviceinterfaces "queryorchestration/api/serviceInterfaces"
"queryorchestration/internal/collector"
"queryorchestration/internal/database"
"queryorchestration/internal/database/repository"
"queryorchestration/internal/export"
"queryorchestration/internal/otel"
"queryorchestration/internal/query"
"strconv"
"github.com/go-playground/validator/v10"
_ "github.com/lib/pq"
"google.golang.org/grpc"
)
func main() {
ctx := context.Background()
closeTracer := otel.Init(ctx)
defer closeTracer()
database.RunMigrations(os.Getenv("PWD"))
host := "0.0.0.0"
port := 8080
address := net.JoinHostPort(host, strconv.Itoa(port))
lis, err := net.Listen("tcp", address)
if err != nil {
log.Panicf("failed to listen: %v", err)
}
pool := database.GetDBPool(ctx)
db := repository.New(pool)
valid := validator.New()
grpcServer := grpc.NewServer()
serviceinterfaces.RegisterQueryServiceServer(grpcServer, controllers.NewQueryController(*query.New(db), valid))
serviceinterfaces.RegisterExportServiceServer(grpcServer, controllers.NewExportController(*export.New(db), valid))
serviceinterfaces.RegisterJobCollectorServiceServer(grpcServer, controllers.NewJobCollectorController(*collector.New(db), valid))
log.Printf("Listening on port %d", port)
if err := grpcServer.Serve(lis); err != nil {
log.Panicf("Failed to serve: %v", err)
}
}