Class 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)
     );
     
     
    Version:
    $Id: d6b6ca2c903c7afce79f93053598c30f6786463d $
    Author:
    Alexander Sinyagin (sinyagin.alexander@gmail.com)
    • Constructor Detail

      • 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