Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
add filed for gRPC addr to refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
keisku committed Dec 12, 2021
1 parent 6ea7ff5 commit eddb3bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
l.Warn("exit due to a failure of initializing a server", "error", err)
cancel()
}
if err := server.Start(conf.GRPCAddr()); err != nil {
if err := server.Start(); err != nil {
l.Warn("exit due to a failure of starting a server", "error", err)
cancel()
}
Expand Down
6 changes: 4 additions & 2 deletions proto/v1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type Server struct {
logger hclog.Logger
gRPCAddr string
gRPCServer *grpc.Server
gRPCListener net.Listener
gRPCClientConn *grpc.ClientConn
Expand All @@ -28,6 +29,7 @@ func NewServer(ctx context.Context, gRPCAddr, gRPCGWAddr string, l hclog.Logger,
}
return &Server{
logger: l,
gRPCAddr: gRPCAddr,
gRPCServer: grpcServer,
gRPCClientConn: conn,
gRPCGWServer: httpServer,
Expand Down Expand Up @@ -65,9 +67,9 @@ func newgRPCGWServer(ctx context.Context, gRPCAddr, gRPCGWAddr string) (*http.Se
}, conn, nil
}

func (s *Server) Start(gRPCAddr string) error {
func (s *Server) Start() error {
s.logger.Info("Starting gRPC and HTTP servers")
lis, err := net.Listen("tcp", gRPCAddr)
lis, err := net.Listen("tcp", s.gRPCAddr)
if err != nil {
return fmt.Errorf("failed to listen to gRPC addr: %w", err)
}
Expand Down

0 comments on commit eddb3bd

Please sign in to comment.