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

Method OpenTopicURL

pubsub/mempubsub/mem.go:80–96  ·  view source on GitHub ↗

OpenTopicURL opens a pubsub.Topic based on u.

(ctx context.Context, u *url.URL)

Source from the content-addressed store, hash-verified

78
79// OpenTopicURL opens a pubsub.Topic based on u.
80func (o *URLOpener) OpenTopicURL(ctx context.Context, u *url.URL) (*pubsub.Topic, error) {
81 for param := range u.Query() {
82 return nil, fmt.Errorf("open topic %v: invalid query parameter %q", u, param)
83 }
84 topicName := path.Join(u.Host, u.Path)
85 o.mu.Lock()
86 defer o.mu.Unlock()
87 if o.topics == nil {
88 o.topics = map[string]*pubsub.Topic{}
89 }
90 t := o.topics[topicName]
91 if t == nil {
92 t = NewTopic()
93 o.topics[topicName] = t
94 }
95 return t, nil
96}
97
98// OpenSubscriptionURL opens a pubsub.Subscription based on u.
99func (o *URLOpener) OpenSubscriptionURL(ctx context.Context, u *url.URL) (*pubsub.Subscription, error) {

Callers

nothing calls this directly

Calls 2

NewTopicFunction · 0.85
QueryMethod · 0.80

Tested by

no test coverage detected