openSubscription returns a driver.Subscription.
(subscriber *raw.Subscriber, opts *SubscriptionOptions)
| 504 | |
| 505 | // openSubscription returns a driver.Subscription. |
| 506 | func 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. |
| 528 | func (s *subscription) ReceiveBatch(ctx context.Context, maxMessages int) ([]*driver.Message, error) { |
no outgoing calls