Skip to content

Commit

Permalink
Check the response from the database query sooner in the response-con…
Browse files Browse the repository at this point in the history
…sumer
  • Loading branch information
dehort committed Dec 4, 2024
1 parent 2e447b4 commit 78786e5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/response-consumer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ func (this *handler) onMessage(ctx context.Context, msg *k.Message) {

selectResult := baseQuery.Select("id", "status", "response_full").First(&run)

if selectResult.Error != nil {
if errors.Is(selectResult.Error, gorm.ErrRecordNotFound) {
return nil
}

utils.GetLogFromContext(ctx).Errorw("Error fetching run from db", "error", selectResult.Error)
return selectResult.Error
}

if requestType == satMessageHeaderValue {
satellite.SortSatEvents(value.SatEvents)

Expand All @@ -101,15 +110,6 @@ func (this *handler) onMessage(ctx context.Context, msg *k.Message) {
eventsSerialized = utils.MustMarshal(value.RunnerEvents)
}

if selectResult.Error != nil {
if errors.Is(selectResult.Error, gorm.ErrRecordNotFound) {
return nil
}

utils.GetLogFromContext(ctx).Errorw("Error fetching run from db", "error", selectResult.Error)
return selectResult.Error
}

toUpdate := db.Run{
Status: status,
Events: eventsSerialized,
Expand Down

0 comments on commit 78786e5

Please sign in to comment.