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.PublisherClient, topicPath string, opts *TopicOptions)
| 352 | // topic. topicPath must be of the form "projects/<projectID>/topic/<topic>". |
| 353 | // See the package documentation for an example. |
| 354 | func OpenTopicByPath(client *raw.PublisherClient, topicPath string, opts *TopicOptions) (*pubsub.Topic, error) { |
| 355 | if !topicPathRE.MatchString(topicPath) { |
| 356 | return nil, fmt.Errorf("invalid topicPath %q; must match %v", topicPath, topicPathRE) |
| 357 | } |
| 358 | if opts == nil { |
| 359 | opts = &TopicOptions{} |
| 360 | } |
| 361 | bo := sendBatcherOpts.NewMergedOptions(&opts.BatcherOptions) |
| 362 | return pubsub.NewTopic(openTopic(client, topicPath), bo), nil |
| 363 | } |
| 364 | |
| 365 | // openTopic returns the driver for OpenTopic. This function exists so the test |
| 366 | // harness can get the driver interface implementation if it needs to. |