Skip to content

Commit

Permalink
add support for unix domain sockets
Browse files Browse the repository at this point in the history
grpc.NewClient already supports connecting to unix domain sockets, and
accepts a string anyways.

As a quick fix, detect the `address` starting with `unix://` and don't
add the port.

In the long term, we might want to deprecate `host` and `port` cmdline
args in favor of a single `address` arg.
  • Loading branch information
flokli committed Oct 8, 2023
1 parent d1bc03a commit 55d7e7a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mode/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import (
)

func newGRPCClient(cfg *config.Config) (grpc.Client, error) {
addr := fmt.Sprintf("%s:%s", cfg.Server.Host, cfg.Server.Port)
addr := cfg.Server.Host

// as long as the address doesn't start with unix, also add the port.
if !strings.HasPrefix(cfg.Server.Host, "unix://") {
addr = fmt.Sprintf("%s:%s", cfg.Server.Host, cfg.Server.Port)
}

if cfg.Request.Web {
//TODO: remove second arg
return grpc.NewWebClient(addr, cfg.Server.Reflection, false, "", "", "", grpc.Headers(cfg.Request.Header)), nil
Expand Down

0 comments on commit 55d7e7a

Please sign in to comment.