Created
January 4, 2018 09:15
-
-
Save tommy-muehle/5a758ed299577bfad6fe1ba74d4a7fe6 to your computer and use it in GitHub Desktop.
PubSub subscription example
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
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