Created
May 21, 2018 05:28
-
-
Save serinth/5f6e7724f30a69f6b5dcf23a03a8a140 to your computer and use it in GitHub Desktop.
grpc connect with insecure
This file contains hidden or 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
func connect(clientURL string) *grpc.ClientConn { | |
var opts []grpc.DialOption | |
opts = append(opts, grpc.WithInsecure()) | |
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second) | |
defer cancel() | |
con, err := grpc.DialContext(ctx, clientURL, opts...) | |
if err != nil { | |
log.Fatalf("Failed to start gRPC connection: %v", err) | |
} | |
return con | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment