Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed May 23, 2024
1 parent ddb9f37 commit 0901bd7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions hammer/hammer.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,18 @@ type roundRobinFetcher struct {
f []client.Fetcher
}

func (rr *roundRobinFetcher) Add(f client.Fetcher) {
rr.f = append(rr.f, f)
}

func (rr *roundRobinFetcher) Fetch(ctx context.Context, path string) ([]byte, error) {
func (rr *roundRobinFetcher) next() client.Fetcher {
rr.Lock()
defer rr.Unlock()

klog.V(2).Infof("Using fetcher [%d] to fetch %q", rr.idx, path)
f := rr.f[rr.idx]
rr.idx = (rr.idx + 1) % len(rr.f)

return f
}

func (rr *roundRobinFetcher) Fetch(ctx context.Context, path string) ([]byte, error) {
f := rr.next()
return f(ctx, path)
}

Expand All @@ -106,8 +107,8 @@ func main() {
klog.Exitf("--log_url must be provided")
}

f := roundRobinFetcher{}
var rootURL *url.URL
fetchers := []client.Fetcher{}
for _, s := range logURL {
// url must reference a directory, by definition
if !strings.HasSuffix(s, "/") {
Expand All @@ -118,9 +119,11 @@ func main() {
if err != nil {
klog.Exitf("Invalid log URL: %v", err)
}
f.Add(newFetcher(rootURL))
fetchers = append(fetchers, newFetcher(rootURL))

}
f := roundRobinFetcher{f: fetchers}

var cpRaw []byte
cons := client.UnilateralConsensus(f.Fetch)
hasher := rfc6962.DefaultHasher
Expand Down

0 comments on commit 0901bd7

Please sign in to comment.