From e273d4b62b76fb13f6ec2afccb4ef185a04a171c Mon Sep 17 00:00:00 2001 From: Arul Jeyananth James Edison Date: Mon, 18 Jul 2022 09:23:02 +0530 Subject: [PATCH] integrated wit httpserver for integration integrated with http server --- src/main.go | 17 ++++------------- src/server/grpcServer.go | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main.go b/src/main.go index 3f6a53d..daf4bb4 100644 --- a/src/main.go +++ b/src/main.go @@ -1,24 +1,15 @@ package main import ( - "net" - + integrations "github.com/datasage-io/datasage/src/integrations" grpcServer "github.com/datasage-io/datasage/src/server" - log "github.com/rs/zerolog/log" ) func main() { + //start integration component dependent servers + go integrations.RunServer() //Run a gRPC Server for CLI command processing - listen, err := net.Listen("tcp", ":"+grpcServer.PortNumber) - if err != nil { - log.Error().Msgf("gRPC server failed to listen : %v", err) - } - server := grpcServer.GetNewServer() - //Start service - log.Info().Msgf("gRPC server on %s port started", grpcServer.PortNumber) - if err := server.Serve(listen); err != nil { - log.Error().Msgf("Failed to serve: %v", err) - } + grpcServer.RunServer() } diff --git a/src/server/grpcServer.go b/src/server/grpcServer.go index d7b8aab..37e27ed 100644 --- a/src/server/grpcServer.go +++ b/src/server/grpcServer.go @@ -3,6 +3,7 @@ package server import ( "context" "fmt" + "net" "strconv" "sync" @@ -201,9 +202,13 @@ func (d *DatasourceServer) DeleteDatasource(ctx context.Context, in *ds.DeleteRe // == gRPC Server == // // ================= // -//GetNewServer - gRPC Server -func GetNewServer() *grpc.Server { - log.Info().Msg("gRPC Server Started....") +func RunServer() { + + listen, err := net.Listen("tcp", ":"+PortNumber) + if err != nil { + log.Error().Msgf("gRPC server failed to listen : %v", err) + } + s := grpc.NewServer() grpc_health_v1.RegisterHealthServer(s, health.NewServer()) @@ -213,5 +218,9 @@ func GetNewServer() *grpc.Server { tagpb.RegisterTagServer(s, &TagServer{}) classpb.RegisterClassServer(s, &ClassServer{}) - return s + //Start service + log.Info().Msgf("gRPC server on %s port started", PortNumber) + if err := s.Serve(listen); err != nil { + log.Error().Msgf("Failed to serve: %v", err) + } }