some fixes in structure and imports

This commit is contained in:
Timur Kh.
2025-12-15 22:40:30 +03:00
parent fc8ddbea8a
commit 4e5199c69d
4 changed files with 64 additions and 132 deletions
+2 -17
View File
@@ -11,13 +11,9 @@ import (
"datarush/internal/lms/config"
"datarush/internal/lms/interceptor"
grpcHandlers "datarush/internal/lms/handler/grpc"
httpHandlers "datarush/internal/lms/handler/http"
orderPostgresRepo "datarush/internal/lms/repository/postgres"
"datarush/internal/lms/service"
authPb "datarush/pkg/api/auth"
pb "datarush/pkg/api/order"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/jmoiron/sqlx"
@@ -68,15 +64,10 @@ func runHTTPHandler(s *Server, grpcServerEndpoint *string) error {
gwmux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
err := pb.RegisterOrderServiceHandlerFromEndpoint(ctx, gwmux, *grpcServerEndpoint, opts)
if err != nil {
return err
}
// Register auth service
if err := registerAuthService(ctx, gwmux, s.config.AuthGRPCAddr, opts); err != nil {
log.Printf("failed to register auth service: %v", err)
// Don't fail completely if auth service is not available
}
mux := http.NewServeMux()
@@ -106,7 +97,7 @@ func registerAuthHandlerFromEndpoint(ctx context.Context, gwmux *runtime.ServeMu
// We'll import the proto and register it here
// For now, this is a placeholder that will be called from gateway integration
return nil
}
func getDatabase(cfg config.Config) (*sqlx.DB, error) {
db, err := sqlx.Connect("postgres", cfg.BuildPostgresConnStr())
if err != nil {
@@ -154,12 +145,6 @@ func (s *Server) RegisterServices() {
}
s.redisDB = redisDB
orderRepo := orderPostgresRepo.NewOrderRepository(db, redisDB, &orderPostgresRepo.Config{CacheEnable: true})
orderService := service.NewOrderService(orderRepo)
orderHandler := grpcHandlers.NewOrderHandler(orderService)
pb.RegisterOrderServiceServer(s.grpcServer, orderHandler)
if s.config.GRPCEnableReflection {
reflection.Register(s.grpcServer)
log.Println("gRPC server will start with reflection")
@@ -168,7 +153,7 @@ func (s *Server) RegisterServices() {
func (s *Server) Start() error {
addr := fmt.Sprintf(":%d", s.config.GRPCPort)
lis, err := net.Listen("tcp", addr) //nolint:noctx // no need to use context here
lis, err := net.Listen("tcp", addr)
if err != nil {
return fmt.Errorf("failed to listen: %w", err)
}