moveservicesInterfaces
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user