Skip to content

Commit

Permalink
lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
VihasMakwana committed Dec 12, 2024
1 parent a7d6903 commit c8a4c51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/stanza/fileconsumer/internal/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,20 @@ func (t *fileTracker) restoreArchiveIndex() {
if !t.archiveEnabled() {
return
}
archiveIndex := 0
byteIndex, err := t.persister.Get(context.Background(), archiveIndexKey)
if err != nil {
t.set.Logger.Error("error while reading the archiveIndexKey. Starting from 0", zap.Error(err))
return
}
archiveIndex, err = byteToIndex(byteIndex)
t.archiveIndex, err = byteToIndex(byteIndex)
if err != nil {
t.set.Logger.Error("error getting read index. Starting from 0", zap.Error(err))
return
} else if archiveIndex < 0 || archiveIndex >= t.pollsToArchive {
} else if t.archiveIndex < 0 || t.archiveIndex >= t.pollsToArchive {
// safety check. It can happen if `polls_to_archive` was changed.
// It's best if we reset the index or else we might end up writing invalid keys
t.set.Logger.Warn("the read index was found, but it exceeds the bounds. Starting from 0")
return
t.archiveIndex = 0
}
t.archiveIndex = archiveIndex
}

func (t *fileTracker) archive(metadata *fileset.Fileset[*reader.Metadata]) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/stanza/operator/persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ func (p scopedPersister) Delete(ctx context.Context, key string) error {
}

func (p scopedPersister) Batch(ctx context.Context, ops ...storage.Operation) error {
for _, op := range ops {
op.Key = fmt.Sprintf("%s.%s", p.scope, op.Key)
}
return p.Persister.Batch(ctx, ops...)
}

0 comments on commit c8a4c51

Please sign in to comment.