gitlab4j-api icon indicating copy to clipboard operation
gitlab4j-api copied to clipboard

Request throttling to stay under the rate limit

Open pvlasov opened this issue 2 years ago • 0 comments

I love gitlab4j - it makes my life so much easier! When using it I ran into "Rate limit exceeded" exception several times. The documentation doesn't mention support of request throttling and I didn't see anything related to it in the GitLabApi class.

So, I implemented request throttling myself in https://github.com/Nasdanika-Models/gitlab/blob/main/model/src/main/java/org/nasdanika/models/gitlab/util/ThrottlingHandler.java. It is wired to the GitLabApi class as a logging handler as shown here - https://github.com/Nasdanika-Models/gitlab/blob/main/model/src/main/java/org/nasdanika/models/gitlab/util/Loader.java#L110.

It works for me, but using a logging handler to do non-logging work it is a work-around/hack. It would be great if request throttling was supported natively by GitLabApi. Please feel free to reuse my code! If it is already implemented - please document it, so I know how to use it!

pvlasov avatar Sep 13 '23 10:09 pvlasov