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

Function openSubscription

pubsub/gcppubsubv2/gcppubsub.go:506–525  ·  view source on GitHub ↗

openSubscription returns a driver.Subscription.

(subscriber *raw.Subscriber, opts *SubscriptionOptions)

Source from the content-addressed store, hash-verified

504
505// openSubscription returns a driver.Subscription.
506func openSubscription(subscriber *raw.Subscriber, opts *SubscriptionOptions) *subscription {
507 if opts == nil {
508 opts = &SubscriptionOptions{}
509 }
510 if opts.MaxBatchSize == 0 {
511 opts.MaxBatchSize = defaultRecvBatcherOpts.MaxBatchSize
512 }
513 // Construct a context that's used (repeatedly if necessary) to call Receive.
514 // It never expires; the Receive may last forever.
515 // The cancel function is used during shutdown.
516 ctx, cancel := context.WithCancel(context.Background())
517 return &subscription{
518 subscriber: subscriber,
519 options: opts,
520 receiving: false,
521 receiveCtx: ctx,
522 receiveCancel: cancel,
523 acks: map[driver.AckID]*ackableMsg{},
524 }
525}
526
527// ReceiveBatch implements driver.Subscription.ReceiveBatch.
528func (s *subscription) ReceiveBatch(ctx context.Context, maxMessages int) ([]*driver.Message, error) {

Callers 3

createSubscriptionFunction · 0.70
OpenSubscriptionFunction · 0.70

Calls

no outgoing calls

Tested by 2

createSubscriptionFunction · 0.56