-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Rate Limit Headers #327
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, but what the crazy calculation do you do here?
hour - value in second
System.currentTimeMillis() - return millisecond
(millisecond + second)/ 1000L - strange unpredictable type of second, we can say this type of seconds as X.
By javadoc:
public Date(long date)
date the milliseconds since January 1, 1970, 00:00:00 GMT.
if we will use new Date( X ), then we can't predict what type of date we will receive.
@stephenc @KostyaSha @kohsuke
with this new code you broke reset time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! Read the comment in GHRateLimit... for crazy reasons that class stores the date in Date with seconds expressed as milliseconds.
Without this fixup the reset date will be incorrect as returned by
GHRateLimit.getResetDate()
I have comments indicating that it be madness... but actually is the fix if least harm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack the adding of an hours seconds should be outside of the division, but this will still give a result in the future for GHE and as GHE does not have a rate limit...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read about "this is madness, storing the date as seconds in a Date object"
but very confused by the division.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/kohsuke/github-api/blob/4ee3086b6dcb46913f1341b2500a4790db5813d6/src/main/java/org/kohsuke/github/GHRateLimit.java#L31 is why we need to do the division... and that is madness... but fixing that madness is orthogonal to this enhancement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#329 will fix the algebra... but it is not strictly required as a limit of no limit expiring in 3.6 seconds or expiring in 1 h is still a limit of no limit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But without correcting for the 1000 fold factor then GHE would say it had a limit of 1000000 being refreshed on Tue Jun 20 01:41:44 IST 48997 which allows 21 API calls per year... so code that uses the rate limit to pre-throttle will run unnecessarily slow on GHE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #329 code running against GHE and proactively throttling will make 277 API requests per second, while without #329 it might try and make 277777 requests per second as its upper limit... which is probably unatainable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or were you accessing the public field directly (oh how I love the way people make fields public in Java and make migration very difficult without breaking backwards compatibility)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with this, fixing this madness must doing not in this issue.