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

Function OpenTopicByPath

pubsub/gcppubsubv2/gcppubsub.go:346–353  ·  view source on GitHub ↗

OpenTopicByPath returns a *pubsub.Topic backed by an existing GCP PubSub topic. topicPath must be of the form "projects/ /topic/ ". See the package documentation for an example.

(client *raw.Client, topicPath string, opts *TopicOptions)

Source from the content-addressed store, hash-verified

344// topic. topicPath must be of the form "projects/<projectID>/topic/<topic>".
345// See the package documentation for an example.
346func OpenTopicByPath(client *raw.Client, topicPath string, opts *TopicOptions) (*pubsub.Topic, error) {
347 matches := topicPathRE.FindStringSubmatch(topicPath)
348 if len(matches) != 2 {
349 return nil, fmt.Errorf("invalid topicPath %q; must match %v", topicPath, topicPathRE)
350 }
351 topicName := matches[1]
352 return OpenTopic(client, topicName, opts), nil
353}
354
355// openTopic returns the driver for OpenTopic. This function exists so the test
356// harness can get the driver interface implementation if it needs to.

Callers 2

TestOpenTopicFunction · 0.70
OpenTopicURLMethod · 0.70

Calls 1

OpenTopicFunction · 0.70

Tested by 1

TestOpenTopicFunction · 0.56