Skip to content

Commit

Permalink
Don't return error from randomPercentage:
Browse files Browse the repository at this point in the history
I was just ignoring the error, so an error
is now just returned as 0.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Nov 20, 2024
1 parent 0e21ae2 commit 9746f9e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/iso/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ type Handler struct {
MagicString string
}

func randomPercentage(precision int64) (float64, error) {
func randomPercentage(precision int64) float64 {
random, err := rand.Int(rand.Reader, big.NewInt(precision))
if err != nil {
return 0, err
return 0
}

Check warning on line 53 in internal/iso/iso.go

View check run for this annotation

Codecov / codecov/patch

internal/iso/iso.go#L52-L53

Added lines #L52 - L53 were not covered by tests

return float64(random.Int64()) / float64(precision), nil
return float64(random.Int64()) / float64(precision)
}

func (h *Handler) RoundTrip(req *http.Request) (*http.Response, error) {
Expand Down Expand Up @@ -143,7 +143,7 @@ func (h *Handler) RoundTrip(req *http.Request) (*http.Response, error) {
// In testing, it was observed that about 3000 HTTP 206 requests are made per ISO mount.
// 0.002% gives us about 5, +/- 3, log messages per ISO mount.
// We're optimizing for showing "enough" log messages so that progress can be observed.
if p, _ := randomPercentage(10000); p < 0.002 {
if p := randomPercentage(10000); p < 0.002 {
log.Info("HTTP GET method received with a 206 status code")
}

Check warning on line 148 in internal/iso/iso.go

View check run for this annotation

Codecov / codecov/patch

internal/iso/iso.go#L147-L148

Added lines #L147 - L148 were not covered by tests

Expand Down

0 comments on commit 9746f9e

Please sign in to comment.