com.palantir.conjure.java.api.errors.QosException.throttle()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(55)

本文整理了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

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();
}

相关文章

微信公众号

最新文章

更多