Skip to content

Commit

Permalink
integrated wit httpserver for integration
Browse files Browse the repository at this point in the history
integrated with http server
  • Loading branch information
ArulJeyananth committed Jul 18, 2022
1 parent 8a03f02 commit e273d4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 4 additions & 13 deletions src/main.go
Original file line number Diff line number Diff line change
@@ -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()

}
17 changes: 13 additions & 4 deletions src/server/grpcServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"context"
"fmt"
"net"
"strconv"
"sync"

Expand Down Expand Up @@ -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())

Expand All @@ -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)
}
}

0 comments on commit e273d4b

Please sign in to comment.