Skip to content

Commit

Permalink
[CLOB-930] Add support for domain sockets for gRPC server and gRPC.
Browse files Browse the repository at this point in the history
ctx.Done() support was added in 0.50 with cosmos#15041
server start up time was removed in 0.50 with cosmos#15041
  • Loading branch information
lcwik committed Dec 6, 2023
1 parent 53f0196 commit 2768f92
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion server/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"strings"

"google.golang.org/grpc"

Expand Down Expand Up @@ -74,7 +75,17 @@ func NewGRPCServer(clientCtx client.Context, app types.Application, cfg config.G
// Otherwise, an error is returned. The caller is expected to provide a Context
// that is properly canceled or closed to indicate the server should be stopped.
func StartGRPCServer(ctx context.Context, logger log.Logger, cfg config.GRPCConfig, grpcSrv *grpc.Server) error {
listener, err := net.Listen("tcp", cfg.Address)
var proto, addr string
parts := strings.SplitN(cfg.Address, "://", 2)
// Default to using 'tcp' to maintain backwards compatibility with configurations that don't specify
// the network to use.
if len(parts) != 2 {
proto = "tcp"
addr = cfg.Address
} else {
proto, addr = parts[0], parts[1]
}
listener, err := net.Listen(proto, addr)
if err != nil {
return fmt.Errorf("failed to listen on address %s: %w", cfg.Address, err)
}
Expand Down

0 comments on commit 2768f92

Please sign in to comment.