OpenSubscriptionByPath returns a *pubsub.Subscription backed by an existing GCP PubSub subscription. subscriptionPath must be of the form "projects/ /subscriptions/ ". See the package documentation for an example.
(client *raw.SubscriberClient, subscriptionPath string, opts *SubscriptionOptions)
| 500 | // "projects/<projectID>/subscriptions/<subscription>". |
| 501 | // See the package documentation for an example. |
| 502 | func OpenSubscriptionByPath(client *raw.SubscriberClient, subscriptionPath string, opts *SubscriptionOptions) (*pubsub.Subscription, error) { |
| 503 | if !subscriptionPathRE.MatchString(subscriptionPath) { |
| 504 | return nil, fmt.Errorf("invalid subscriptionPath %q; must match %v", subscriptionPath, subscriptionPathRE) |
| 505 | } |
| 506 | |
| 507 | dsub := openSubscription(client, subscriptionPath, opts) |
| 508 | recvOpts := *defaultRecvBatcherOpts |
| 509 | recvOpts.MaxBatchSize = dsub.options.MaxBatchSize |
| 510 | rbo := recvOpts.NewMergedOptions(&dsub.options.ReceiveBatcherOptions) |
| 511 | abo := ackBatcherOpts.NewMergedOptions(&dsub.options.AckBatcherOptions) |
| 512 | return pubsub.NewSubscription(dsub, rbo, abo), nil |
| 513 | } |
| 514 | |
| 515 | // openSubscription returns a driver.Subscription. |
| 516 | func openSubscription(client *raw.SubscriberClient, subscriptionPath string, opts *SubscriptionOptions) *subscription { |