MCPcopy Create free account
hub / github.com/google/go-cloud / Example_openSubscriptionFromURL

Function Example_openSubscriptionFromURL

pubsub/mempubsub/example_test.go:49–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49func Example_openSubscriptionFromURL() {
50 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.
51 // PRAGMA: On gocloud.dev, add a blank import: _ "gocloud.dev/pubsub/mempubsub"
52 // PRAGMA: On gocloud.dev, hide lines until the next blank line.
53 ctx := context.Background()
54
55 // Create a topic.
56 topic, err := pubsub.OpenTopic(ctx, "mem://topicA")
57 if err != nil {
58 log.Fatal(err)
59 }
60 defer topic.Shutdown(ctx)
61
62 // Create a subscription connected to that topic.
63 subscription, err := pubsub.OpenSubscription(ctx, "mem://topicA")
64 if err != nil {
65 log.Fatal(err)
66 }
67 defer subscription.Shutdown(ctx)
68}
69
70func Example_openTopicFromURL() {
71 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.

Callers

nothing calls this directly

Calls 3

OpenTopicFunction · 0.92
OpenSubscriptionFunction · 0.92
ShutdownMethod · 0.65

Tested by

no test coverage detected