Skip to content

Commit 7db03c5

Browse files
author
Sergiu Ghitea
committed
Skip notifications if validAfter has not been reached
1 parent 2044c5d commit 7db03c5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

driver/sql/projection_notification_processor.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"runtime"
66
"sync"
7+
"time"
78

89
"github.com/hellofresh/goengine"
910
"github.com/pkg/errors"
@@ -116,13 +117,19 @@ func (b *projectionNotificationProcessor) Queue(ctx context.Context, notificatio
116117
}
117118

118119
func (b *projectionNotificationProcessor) startProcessor(ctx context.Context, handler ProcessHandler) {
120+
ProcessorLoop:
119121
for {
120122
select {
121123
case <-b.done:
122124
return
123125
case <-ctx.Done():
124126
return
125127
case notification := <-b.queue:
128+
if notification != nil && notification.ValidAfter.After(time.Now()) {
129+
b.queue <- notification
130+
continue ProcessorLoop
131+
}
132+
126133
// Execute the notification
127134
b.metrics.StartNotificationProcessing(notification)
128135
if err := handler(ctx, notification, b.Queue); err != nil {

0 commit comments

Comments
 (0)