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

Function OpenTopicByPath

pubsub/gcppubsub/gcppubsub.go:354–363  ·  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.PublisherClient, topicPath string, opts *TopicOptions)

Source from the content-addressed store, hash-verified

352// topic. topicPath must be of the form "projects/<projectID>/topic/<topic>".
353// See the package documentation for an example.
354func 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.

Callers 3

ExampleOpenTopicFunction · 0.92
TestOpenTopicFunction · 0.70
OpenTopicURLMethod · 0.70

Calls 2

NewMergedOptionsMethod · 0.80
openTopicFunction · 0.70

Tested by 2

ExampleOpenTopicFunction · 0.74
TestOpenTopicFunction · 0.56