本文整理了Java中com.palantir.conjure.java.api.errors.QosException.throttle
方法的一些代码示例,展示了QosException.throttle
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QosException.throttle
方法的具体详情如下:
包路径:com.palantir.conjure.java.api.errors.QosException
类名称:QosException
方法名:throttle
暂无
代码示例来源:origin: com.palantir.conjure.java.runtime/okhttp-clients
private static QosException handle429(Response response) {
String duration = response.header(HttpHeaders.RETRY_AFTER);
if (duration == null) {
log.debug("Received 429 response, throwing QosException to trigger delayed retry");
return QosException.throttle();
} else {
log.debug("Received 429 response, throwing QosException to trigger delayed retry",
SafeArg.of("duration", duration));
return QosException.throttle(Duration.ofSeconds(Long.parseLong(duration)));
}
}
代码示例来源:origin: palantir/conjure-java-runtime
private static QosException handle429(Response response) {
String duration = response.header(HttpHeaders.RETRY_AFTER);
if (duration == null) {
log.debug("Received 429 response, throwing QosException to trigger delayed retry");
return QosException.throttle();
} else {
log.debug("Received 429 response, throwing QosException to trigger delayed retry",
SafeArg.of("duration", duration));
return QosException.throttle(Duration.ofSeconds(Long.parseLong(duration)));
}
}
代码示例来源:origin: palantir/conjure-java-runtime
@Test
public void testThrottle_withDuration() throws Exception {
QosException exception = QosException.throttle(Duration.ofMinutes(2));
Response response = mapper.toResponse(exception);
assertThat(response.getStatus()).isEqualTo(429);
assertThat(response.getHeaders()).containsEntry("Retry-After", ImmutableList.of("120"));
}
代码示例来源:origin: palantir/conjure-java-runtime
@Test
public void testThrottle_withoutDuration() throws Exception {
QosException exception = QosException.throttle();
Response response = mapper.toResponse(exception);
assertThat(response.getStatus()).isEqualTo(429);
assertThat(response.getHeaders()).isEmpty();
}
内容来源于网络,如有侵权,请联系作者删除!