pubsub: fix panic on Topic.ResumePublish
When Topic.ResumePublish is called before Topic.Publish,
the underlying scheduler is not initialized yet, leading to a panic.
This patch makes sure scheduler.Resume is only called
when the scheduler is not nil.
@@ -584,5 +584,12 @@ func (t *Topic) publishMessageBundle(ctx context.Context, bms []*bundledMessage)
// encountered while publishing, to prevent messages from being published
// out of order.
func (t *Topic) ResumePublish(orderingKey string) {
+ t.mu.RLock()
+ noop := t.scheduler == nil
+ t.mu.RUnlock()
+ if noop {
+ return
+ }
+
t.scheduler.Resume(orderingKey)
}
