Skip to content

Commit

Permalink
Merge pull request #953 from kaleido-io/missingdata
Browse files Browse the repository at this point in the history
Distinguish "message not available" from "message missing data"
  • Loading branch information
peterbroadhurst authored Aug 10, 2022
2 parents a5b068c + e820054 commit 5ede657
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/events/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,13 @@ func (ag *aggregator) processMessage(ctx context.Context, manifest *core.BatchMa
cro = data.CRORequirePublicBlobRefs
}
msg, data, dataAvailable, err := ag.data.GetMessageWithDataCached(ctx, msgEntry.ID, cro)
if err != nil {
switch {
case err != nil:
return err
}
if !dataAvailable {
case msg == nil:
l.Debugf("Message '%s' in batch '%s' is not yet available", msgEntry.ID, manifest.ID)
return nil
case !dataAvailable:
l.Errorf("Message '%s' in batch '%s' is missing data", msgEntry.ID, manifest.ID)
return nil
}
Expand Down
13 changes: 13 additions & 0 deletions internal/events/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,19 @@ func TestProcessMsgFailData(t *testing.T) {
mdm.AssertExpectations(t)
}

func TestProcessMsgNoData(t *testing.T) {
ag, cancel := newTestAggregator()
defer cancel()

mdm := ag.data.(*datamocks.Manager)
mdm.On("GetMessageWithDataCached", ag.ctx, mock.Anything, data.CRORequirePins).Return(nil, nil, false, nil)

err := ag.processMessage(ag.ctx, &core.BatchManifest{}, &core.Pin{Masked: true, Sequence: 12345}, 10, &core.MessageManifestEntry{}, nil)
assert.NoError(t, err)

mdm.AssertExpectations(t)
}

func TestProcessMsgFailMissingData(t *testing.T) {
ag, cancel := newTestAggregator()
defer cancel()
Expand Down

0 comments on commit 5ede657

Please sign in to comment.