Skip to content

Commit

Permalink
Fix nil rate limit when adjust-delay is false
Browse files Browse the repository at this point in the history
  • Loading branch information
PolovinaD committed Mar 30, 2022
1 parent 02e1597 commit f0202b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,17 @@ errHandle:
err := githubV4Client.Query(context.Background(), result, *variables)
duration := time.Since(start).Milliseconds() - int64(time.Millisecond)
delayMutex.Lock()
rateLimit = &result.RateLimit
if err != nil {
handleGraphQLAPIError(err)
delayMutex.Unlock()
goto errHandle
}

if adjustDelay {
adjustDelayTime(result.RateLimit)
adjustDelayTime(*rateLimit)
}
sleep := int64(requestDelay*result.RateLimit.Cost)*int64(time.Millisecond) - duration
sleep := int64(requestDelay*rateLimit.Cost)*int64(time.Millisecond) - duration
delayMutex.Unlock()
time.Sleep(time.Duration(sleep))
}
Expand Down

0 comments on commit f0202b2

Please sign in to comment.