docs(pubsub): add emulator instructions to doc
@@ -136,5 +136,26 @@ Slow Message Processing
For use cases where message processing exceeds 30 minutes, we recommend using
the base client in a pull model, since long-lived streams are periodically killed
by firewalls. See the example at https://godoc.org/cloud.google.com/go/pubsub/apiv1#example-SubscriberClient-Pull-LengthyClientProcessing
+
+Emulator
+
+To use an emulator with this library, you can set the PUBSUB_EMULATOR_HOST
+environment variable to the address at which your emulator is running. This will
+send requests to that address instead of to Cloud Pub/Sub. You can then create
+and use a client as usual:
+
+ // Set PUBSUB_EMULATOR_HOST environment variable.
+ err := os.Setenv("PUBSUB_EMULATOR_HOST", "localhost:9000")
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // Create client as usual.
+ client, err := pubsub.NewClient(ctx, "my-project-id")
+ if err != nil {
+ // TODO: Handle error.
+ }
+ defer client.Close()
+
+
*/
package pubsub // import "cloud.google.com/go/pubsub"
