Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the readers to have a single reader class #121

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions hammer/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
)

// NewLeafReader creates a LeafReader.
// The next function provides a strategy for which leaves will be read.
// Custom implementations can be passed, or use RandomNextLeaf or MonotonicallyIncreasingNextLeaf.
func NewLeafReader(tracker *client.LogStateTracker, f client.Fetcher, next func(uint64) uint64, bundleSize int, throttle <-chan bool, errchan chan<- error) *LeafReader {
mhutchinson marked this conversation as resolved.
Show resolved Hide resolved
if bundleSize <= 0 {
panic("bundleSize must be > 0")
Expand All @@ -48,7 +50,7 @@ func NewLeafReader(tracker *client.LogStateTracker, f client.Fetcher, next func(
}
}

// LeafReader reads random leaves across the tree.
// LeafReader reads leaves from the tree.
type LeafReader struct {
tracker *client.LogStateTracker
f client.Fetcher
Expand Down Expand Up @@ -76,13 +78,13 @@ func (r *LeafReader) Run(ctx context.Context) {
continue
}
i := r.next(size)
if i == size {
if i >= size {
continue
}
klog.V(2).Infof("LeafReader getting %d", i)
_, err := r.getLeaf(ctx, i, size)
if err != nil {
r.errchan <- fmt.Errorf("Failed to get random leaf: %v", err)
r.errchan <- fmt.Errorf("Failed to get leaf: %v", err)
mhutchinson marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading