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)
| 344 | // topic. topicPath must be of the form "projects/<projectID>/topic/<topic>". |
| 345 | // See the package documentation for an example. |
| 346 | func 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. |