google / go-github

Go library for accessing the GitHub v3 API

Home Page:https://pkg.go.dev/github.com/google/go-github/v62/github

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: Add an option to wait for primary rate limit reset and retry instead of erroring out

erezrokah opened this issue Β· comments

Hi πŸ‘‹ 🐰

This is mostly the same issue as #1920

For our use case we'd prefer to wait until the reset time instead of erroring out when the primary rate limit is reached.
The only way I found to do it at the moment is wrap each API call with a check to github.RateLimitError.

We can't use roundtripper as checkRateLimitBeforeDo happens before. I tried wrapping BareDo with my own implementation but couldn't get it to work due to how the services and client are initialized.

If bypassRateLimitCheck was exported I might have been able to use it to bypass the check and get use a roundtripper but that doesn't seem very elegant.

Can you suggestion a solution?

What did you think of my earlier suggestion?

That would work great for us

OK, cool. Would you like to submit a PR, @erezrokah , or would you prefer that I open this up to our other contributors?

I can open a PR if you point me to the right direction. Is the suggestion a new pattern to the repo or an existing pattern there's a reference for?

I believe this would be new functionality. As such, I have not explored the solution space.
So if you don't have a plan in mind at this point, then maybe we should let another developer tackle this problem, as it will involve some investigation, some thought, and some experimentation to get it right.

I'm ok with that no worries, wanted to make sure I'm not missing anything. I'll take a look and reach out if I'm blocked

Opened a PR #3117, feedback welcomed