diff --git a/internal/pkgs/grpc/grpcclient.go b/internal/pkgs/grpc/grpcclient.go index 129baa7..a5a95b0 100644 --- a/internal/pkgs/grpc/grpcclient.go +++ b/internal/pkgs/grpc/grpcclient.go @@ -4,6 +4,7 @@ package grpc import ( "context" + "fmt" "time" "givc/internal/pkgs/types" @@ -65,7 +66,18 @@ func NewClient(cfg *types.EndpointConfig, allowLongWaits bool) (*grpc.ClientConn } options = append(options, grpc.WithChainUnaryInterceptor(interceptors...)) - return grpc.NewClient(cfg.Transport.Address+":"+cfg.Transport.Port, options...) + // Set address + var addr string + switch cfg.Transport.Protocol { + case "tcp": + addr = cfg.Transport.Address + ":" + cfg.Transport.Port + case "unix": + addr = cfg.Transport.Address + default: + return nil, fmt.Errorf("unsupported protocol: %s", cfg.Transport.Protocol) + } + + return grpc.NewClient(addr, options...) } func withOutgoingContext(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { diff --git a/internal/pkgs/grpc/grpcserver.go b/internal/pkgs/grpc/grpcserver.go index 50776c3..9c01f3c 100644 --- a/internal/pkgs/grpc/grpcserver.go +++ b/internal/pkgs/grpc/grpcserver.go @@ -85,7 +85,18 @@ func (s *GrpcServer) ListenAndServe(ctx context.Context, started chan struct{}) var err error var listener net.Listener - addr := s.config.Transport.Address + ":" + s.config.Transport.Port + var addr string + + // Set address + switch s.config.Transport.Protocol { + case "tcp": + addr = s.config.Transport.Address + ":" + s.config.Transport.Port + case "unix": + addr = s.config.Transport.Address + default: + return fmt.Errorf("unsupported protocol: %s", s.config.Transport.Protocol) + } + for i := 0; i < LISTENER_RETRIES; i++ { listener, err = net.Listen(s.config.Transport.Protocol, addr) if err != nil {