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

Function OpenTopic

pubsub/gcppubsub/gcppubsub.go:340–347  ·  view source on GitHub ↗

OpenTopic returns a *pubsub.Topic backed by an existing GCP PubSub topic in the given projectID. topicName is the last part of the full topic path, e.g., "foo" from "projects/ /topic/foo". See the package documentation for an example.

(client *raw.PublisherClient, projectID gcp.ProjectID, topicName string, opts *TopicOptions)

Source from the content-addressed store, hash-verified

338// path, e.g., "foo" from "projects/<projectID>/topic/foo".
339// See the package documentation for an example.
340func OpenTopic(client *raw.PublisherClient, projectID gcp.ProjectID, topicName string, opts *TopicOptions) *pubsub.Topic {
341 topicPath := fmt.Sprintf("projects/%s/topics/%s", projectID, topicName)
342 if opts == nil {
343 opts = &TopicOptions{}
344 }
345 bo := sendBatcherOpts.NewMergedOptions(&opts.BatcherOptions)
346 return pubsub.NewTopic(openTopic(client, topicPath), bo)
347}
348
349var topicPathRE = regexp.MustCompile("^projects/.+/topics/.+$")
350

Callers 2

TestOpenTopicFunction · 0.70
OpenTopicURLMethod · 0.70

Calls 2

NewMergedOptionsMethod · 0.80
openTopicFunction · 0.70

Tested by 1

TestOpenTopicFunction · 0.56