Skip to content

Commit

Permalink
Create and reuse a single errRequestCancelled variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mostynb committed Mar 15, 2022
1 parent d9766e2 commit 9624090
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cache/disk/findmissing.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type proxyCheck struct {

var errMissingBlob = errors.New("a blob could not be found")

var errRequestCancelled = status.Error(codes.Canceled, "Request was cancelled")

// Optimised implementation of FindMissingBlobs, which batches local index
// lookups and performs concurrent proxy lookups for local cache misses.
// Returns a slice with the blobs that are missing from the cache.
Expand Down Expand Up @@ -71,7 +73,7 @@ func (c *diskCache) findMissingCasBlobsInternal(ctx context.Context, blobs []*pb
if cancelledDueToFailFast {
return errMissingBlob
}
return status.Error(codes.Canceled, "Request was cancelled")
return errRequestCancelled
default:
}

Expand Down Expand Up @@ -114,7 +116,7 @@ func (c *diskCache) findMissingCasBlobsInternal(ctx context.Context, blobs []*pb
if cancelledDueToFailFast {
return errMissingBlob
}
return status.Error(codes.Canceled, "Request was cancelled")
return errRequestCancelled
default:
}

Expand Down Expand Up @@ -145,7 +147,7 @@ func (c *diskCache) findMissingCasBlobsInternal(ctx context.Context, blobs []*pb
if cancelledDueToFailFast {
return errMissingBlob
}
return status.Error(codes.Canceled, "Request was cancelled")
return errRequestCancelled
case <-waitCh: // Everything in the waitgroup has finished.
}
}
Expand Down

0 comments on commit 9624090

Please sign in to comment.