Skip to content

Instantly share code, notes, and snippets.

@tommy-muehle
Created January 4, 2018 09:15
Show Gist options
  • Save tommy-muehle/5a758ed299577bfad6fe1ba74d4a7fe6 to your computer and use it in GitHub Desktop.
Save tommy-muehle/5a758ed299577bfad6fe1ba74d4a7fe6 to your computer and use it in GitHub Desktop.
PubSub subscription example
package main
import (
"context"
"log"
"cloud.google.com/go/pubsub"
)
func main() {
ctx := context.Background()
c, _ := pubsub.NewClient(ctx, "foo")
s, _ := c.CreateSubscription(ctx, "bar", pubsub.SubscriptionConfig{
Topic: c.Topic("foo"),
})
s.ReceiveSettings.MaxOutstandingMessages = 10
s.Receive(ctx, func(ctx context.Context, m *pubsub.Message) {
log.Println(string(m.Data))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment