Class CarefulWire

java.lang.Object
com.jcabi.github.wire.CarefulWire
All Implemented Interfaces:
com.jcabi.http.Wire

@Immutable public final class CarefulWire extends Object implements com.jcabi.http.Wire
Wire that waits if number of remaining request per hour is less than a given threshold.

GitHub sets following headers in each response: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset. If X-RateLimit-Remaining is less than a given threshold, CarefulWire will sleep until a time specified in the X-RateLimit-Reset header. For further information about the GitHub rate limiting see API documentation.

You can use CarefulWire with a GitHub object:

 
 GitHub github = new RtGitHub(
     new RtGitHub().entry().through(CarefulWire.class, 50)
 );
 
 
Since:
0.4
  • Constructor Details

    • CarefulWire

      public CarefulWire(com.jcabi.http.Wire wire, int thrshld)
      Public ctor.
      Parameters:
      wire - Original wire
      thrshld - Threshold of number of remaining requests, below which requests are blocked until reset
  • Method Details