Skip to content

Commit e21f98f

Browse files
committed
panics & fix
1 parent 006d3f9 commit e21f98f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

internal/retry/retry.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ type RetryCallback = func(context.Context, *FuncInfo) error
4444
// This returns an error if the duration limit is reached, or if f() returns a
4545
// non-transient error.
4646
func (r *Retryer) Run(
47-
ctx context.Context, logger *logger.Logger, f ...RetryCallback,
47+
ctx context.Context, logger *logger.Logger, funcs ...RetryCallback,
4848
) error {
49-
return r.runRetryLoop(ctx, logger, f)
49+
return r.runRetryLoop(ctx, logger, funcs)
5050
}
5151

5252
// runRetryLoop contains the core logic for the retry loops.
@@ -80,8 +80,17 @@ func (r *Retryer) runRetryLoop(
8080

8181
eg, egCtx := errgroup.WithContext(ctx)
8282
for i, curFunc := range funcs {
83+
if curFunc == nil {
84+
panic("curFunc should be non-nil")
85+
}
8386

8487
eg.Go(func() error {
88+
if curFunc == nil {
89+
panic("curFunc should be non-nil")
90+
}
91+
if funcinfos[i] == nil {
92+
panic(fmt.Sprintf("funcinfos[%d] should be non-nil", i))
93+
}
8594
err := curFunc(egCtx, funcinfos[i])
8695

8796
if err != nil {

internal/verifier/compare.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ func (verifier *Verifier) FetchAndCompareDocuments(
4141
Run(
4242
givenCtx,
4343
verifier.logger,
44-
readSrcCallback,
45-
readDstCallback,
44+
func(ctx context.Context, fi *retry.FuncInfo) error {
45+
return readSrcCallback(ctx, fi)
46+
},
47+
func(ctx context.Context, fi *retry.FuncInfo) error {
48+
return readDstCallback(ctx, fi)
49+
},
4650
func(ctx context.Context, _ *retry.FuncInfo) error {
4751
var err error
4852
results, docCount, byteCount, err = verifier.compareDocsFromChannels(

0 commit comments

Comments
 (0)