Created
December 24, 2019 02:09
-
-
Save sugamon/35dd66a0534b442f963dc8ac01c78f39 to your computer and use it in GitHub Desktop.
pstest sample
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
ctx := context.Background() | |
// Start a fake server running locally. | |
srv := pstest.NewServer() | |
defer srv.Close() | |
// Connect to the server without using TLS. | |
conn, err := grpc.Dial(srv.Addr, grpc.WithInsecure()) | |
if err != nil { | |
// TODO: Handle error. | |
} | |
defer conn.Close() | |
// Use the connection when creating a pubsub client. | |
client, err := pubsub.NewClient(ctx, "project", option.WithGRPCConn(conn)) | |
if err != nil { | |
// TODO: Handle error. | |
} | |
defer client.Close() | |
_ = client // TODO: Use the client. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment