Skip to content

Commit

Permalink
fix(core): retry also retry un send events
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Apr 23, 2019
1 parent 00e07be commit 889d946
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/entity/event.go
Expand Up @@ -190,7 +190,7 @@ func FindDispatchesWithNonAcknowledgedEvents(db *gorm.DB, before time.Time) ([]*
Joins("JOIN event ON event_dispatch.event_id = event.id").
Where("event.direction = ?", Event_Outgoing).
Where("event_dispatch.acked_at IS NULL").
Where("event_dispatch.sent_at > ?", before).
Where("event_dispatch.sent_at > ? OR event_dispatch.sent_at IS NULL", before).
Find(&dispatches).
Error

Expand Down
4 changes: 4 additions & 0 deletions core/node/mainloop.go
Expand Up @@ -54,6 +54,10 @@ func getRetriableEvents(dispatches []*entity.EventDispatch) []*entity.EventDispa
ret := make([]*entity.EventDispatch, 0)
now := time.Now()
for _, dispatch := range dispatches {
if dispatch.SentAt == nil {
ret = append(ret, dispatch)
continue
}
eventTime := dispatch.SentAt.Add(time.Duration(dispatch.RetryBackoff) * time.Millisecond)
if eventTime.Before(now) {
ret = append(ret, dispatch)
Expand Down

0 comments on commit 889d946

Please sign in to comment.