From ff7159f2ba24536ef3585f1ab8230ea6618ebc24 Mon Sep 17 00:00:00 2001 From: Alexsandro Souza Date: Sat, 5 Sep 2020 18:41:21 +0100 Subject: [PATCH] Remove port from server start --- client/client_test.go | 2 +- server/server.go | 9 ++++----- server/server_example.go | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index 0124290..f09c22d 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -32,7 +32,7 @@ func startServerWithTLS() grpc_server.GrpcServer { svr.RegisterService(func(server *grpc.Server) { helloworld.RegisterGreeterServer(server, &testdata.MockedService{}) }) - svr.Start("localhost", 8989) + svr.Start("localhost:8989") return svr } diff --git a/server/server.go b/server/server.go index 1ad6c98..32c5538 100644 --- a/server/server.go +++ b/server/server.go @@ -20,7 +20,7 @@ import ( //Fiji GRPC server interface type GrpcServer interface { - Start(address string, port uint) error + Start(address string) error AwaitTermination(shutdownHook func()) RegisterService(reg func(*grpc.Server)) GetListener() net.Listener @@ -110,10 +110,9 @@ func (s grpcServer) RegisterService(reg func(*grpc.Server)) { } // Start the GRPC server -func (s *grpcServer) Start(address string, port uint) error { +func (s *grpcServer) Start(addr string) error { var err error - add := fmt.Sprintf("%s:%d", address, port) - s.listener, err = net.Listen("tcp", add) + s.listener, err = net.Listen("tcp", addr) if err != nil { msg := fmt.Sprintf("Failed to listen: %v", err) @@ -122,7 +121,7 @@ func (s *grpcServer) Start(address string, port uint) error { go s.serv() - log.Infof("grpcServer started on port: %d ", port) + log.Infof("gRPC Server started on %s ", addr) return nil } diff --git a/server/server_example.go b/server/server_example.go index 2dcd6f6..39678ba 100644 --- a/server/server_example.go +++ b/server/server_example.go @@ -36,7 +36,7 @@ func ServerInitialization() { builder.EnableReflection(true) s := builder.Build() s.RegisterService(serviceRegister) - err := s.Start("0.0.0.0", 50051) + err := s.Start("0.0.0.0:50051") if err != nil { log.Fatalf("%v", err) } @@ -57,7 +57,7 @@ func ServerInitializationWithTLS() { s := builder.Build() s.RegisterService(serviceRegister) - err := s.Start("0.0.0.0", 50051) + err := s.Start("0.0.0.0:50051") if err != nil { log.Fatalf("%v", err) }