Golang GRPC Unix Socket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conn, err := grpc.Dial( | |
s.rpcSocketPath, | |
grpc.WithInsecure(), | |
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { | |
return net.DialTimeout("unix", addr, timeout) | |
})) | |
if err != nil { | |
log.Fatalf("did not connect: %v", err) | |
} | |
defer conn.Close() | |
c := pb.NewGreeterClient(conn) | |
// Contact the server and print out its response. | |
hostname, _ := os.Hostname() | |
r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: hostname + "-worker"}) | |
if err != nil { | |
log.Fatalf("could not greet: %v", err) | |
} | |
log.Printf("Greeting: %s", r.Message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't it work with
unix://addr
?