Skip to content

Commit

Permalink
chore(grpc): comment code
Browse files Browse the repository at this point in the history
  • Loading branch information
isaqueveras committed Apr 13, 2024
1 parent 4108ad0 commit 3977feb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func main() {
logg.Fatal("Error while serving the server HTTP: ", err)
}

if err := server.ServerGRPC(); err != nil {
logg.Fatal("Error while serving the server GRPC: ", err)
}
// if err := server.ServerGRPC(); err != nil {
// logg.Fatal("Error while serving the server GRPC: ", err)
// }

if err := group.Wait(); err != nil {
logg.Fatal("Error while serving the servers: ", err)
Expand Down
116 changes: 58 additions & 58 deletions server/grpc.go
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
// Copyright (c) 2023 Isaque Veras
// Use of this source code is governed by MIT style
// license that can be found in the LICENSE file.
// // Copyright (c) 2023 Isaque Veras
// // Use of this source code is governed by MIT style
// // license that can be found in the LICENSE file.

package server

import (
"net"
"os"
"os/signal"
"syscall"
// import (
// "net"
// "os"
// "os/signal"
// "syscall"

grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpcRecovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
gogrpc "google.golang.org/grpc"
"google.golang.org/grpc/reflection"
// grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
// grpcRecovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
// gogrpc "google.golang.org/grpc"
// "google.golang.org/grpc/reflection"

"github.com/isaqueveras/powersso/delivery/grpc/auth"
"github.com/isaqueveras/powersso/middleware"
"github.com/isaqueveras/powersso/oops"
"github.com/isaqueveras/powersso/utils"
)
// "github.com/isaqueveras/powersso/delivery/grpc/auth"
// "github.com/isaqueveras/powersso/middleware"
// "github.com/isaqueveras/powersso/oops"
// "github.com/isaqueveras/powersso/utils"
// )

func (s *Server) ServerGRPC() (err error) {
if !s.cfg.Server.StartGRPC {
return
}
// func (s *Server) ServerGRPC() (err error) {
// if !s.cfg.Server.StartGRPC {
// return
// }

var (
listen net.Listener
serverGRPC = gogrpc.NewServer(
// TODO: grpc.Creds(credentials.NewTLS(nil)),
gogrpc.UnaryInterceptor(
grpcMiddleware.ChainUnaryServer(
middleware.GRPCZap(),
grpcRecovery.UnaryServerInterceptor(
grpcRecovery.WithRecoveryHandler(utils.PanicRecovery),
),
),
),
)
)
// var (
// listen net.Listener
// serverGRPC = gogrpc.NewServer(
// // TODO: grpc.Creds(credentials.NewTLS(nil)),
// gogrpc.UnaryInterceptor(
// grpcMiddleware.ChainUnaryServer(
// middleware.GRPCZap(),
// grpcRecovery.UnaryServerInterceptor(
// grpcRecovery.WithRecoveryHandler(utils.PanicRecovery),
// ),
// ),
// ),
// )
// )

s.logg.Info("Server GRPC is running")
if s.cfg.Server.IsModeDevelopment() {
s.logg.Debug("RUNNING IN DEVELOPMENT: REFLECTION ON")
reflection.Register(serverGRPC)
}
// s.logg.Info("Server GRPC is running")
// if s.cfg.Server.IsModeDevelopment() {
// s.logg.Debug("RUNNING IN DEVELOPMENT: REFLECTION ON")
// reflection.Register(serverGRPC)
// }

go func(server *gogrpc.Server) {
signalOS := make(chan os.Signal, 1)
signal.Notify(signalOS, syscall.SIGINT, syscall.SIGTERM)
for range signalOS {
server.GracefulStop()
return
}
}(serverGRPC)
// go func(server *gogrpc.Server) {
// signalOS := make(chan os.Signal, 1)
// signal.Notify(signalOS, syscall.SIGINT, syscall.SIGTERM)
// for range signalOS {
// server.GracefulStop()
// return
// }
// }(serverGRPC)

// TODO: use address in config file
if listen, err = net.Listen("tcp", "localhost:50050"); err != nil {
return oops.Err(err)
}
// // TODO: use address in config file
// if listen, err = net.Listen("tcp", "localhost:50050"); err != nil {
// return oops.Err(err)
// }

auth.RegisterAuthenticationServer(serverGRPC, &auth.Server{})
// auth.RegisterAuthenticationServer(serverGRPC, &auth.Server{})

s.group.Go(func() error {
return serverGRPC.Serve(listen)
})
// s.group.Go(func() error {
// return serverGRPC.Serve(listen)
// })

return
}
// return
// }

0 comments on commit 3977feb

Please sign in to comment.