Package com.jcabi.github.wire
Class CarefulWire
java.lang.Object
com.jcabi.github.wire.CarefulWire
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.jcabi.http.Responsesend(com.jcabi.http.Request req, String home, String method, Collection<Map.Entry<String, String>> headers, InputStream content, int connect, int read)
-
Constructor Details
-
CarefulWire
public CarefulWire(com.jcabi.http.Wire wire, int thrshld) Public ctor.- Parameters:
wire- Original wirethrshld- Threshold of number of remaining requests, below which requests are blocked until reset
-
-
Method Details
-
send
public com.jcabi.http.Response send(com.jcabi.http.Request req, String home, String method, Collection<Map.Entry<String, String>> headers, InputStream content, int connect, int read) throws IOException- Specified by:
sendin interfacecom.jcabi.http.Wire- Throws:
IOException
-