Skip to content

Commit

Permalink
Remove port from server start
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexsandro Souza committed Sep 5, 2020
1 parent 5c316ae commit ff7159f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
9 changes: 4 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions server/server_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit ff7159f

Please sign in to comment.