Skip to content

Commit

Permalink
fixup rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
carterkozak committed Oct 21, 2024
1 parent fe237ad commit 4a27098
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.AtomicDouble;
import com.google.common.util.concurrent.FutureCallback;
import com.palantir.conjure.java.api.errors.QosReason;
import com.palantir.conjure.java.api.errors.QosReason.DueTo;
import com.palantir.dialogue.Response;
import com.palantir.dialogue.core.LimitedChannel.LimitEnforcement;
import com.palantir.logsafe.SafeArg;
Expand Down Expand Up @@ -103,7 +101,7 @@ enum Behavior {
void onSuccess(Response result, PermitControl control) {
if (Responses.isTooManyRequests(result)
|| Responses.isInternalServerError(result)
|| isQosDueToCustom(result)) {
|| Responses.isQosDueToCustom(result)) {
// 429, 500, or QoS due to a custom reason
control.ignore();
} else if ((Responses.isQosStatus(result) && !Responses.isTooManyRequests(result))
Expand All @@ -127,7 +125,7 @@ void onFailure(Throwable throwable, PermitControl control) {
ENDPOINT_LEVEL() {
@Override
void onSuccess(Response result, PermitControl control) {
if ((Responses.isTooManyRequests(result) && !isQosDueToCustom(result))
if ((Responses.isTooManyRequests(result) && !Responses.isQosDueToCustom(result))
|| Responses.isInternalServerError(result)) {
// non-custom 429 or 500
control.dropped();
Expand Down Expand Up @@ -161,11 +159,6 @@ void onFailure(Throwable _throwable, PermitControl control) {
abstract void onFailure(Throwable throwable, PermitControl control);
}

private static boolean isQosDueToCustom(Response result) {
QosReason reason = DialogueQosReasonDecoder.parse(result);
return DueTo.CUSTOM.equals(reason.dueTo().orElse(null));
}

interface PermitControl {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ static boolean isQosDueToCustom(Response result) {
return false;
}
QosReason reason = DialogueQosReasonDecoder.parse(result);
return DueTo.CUSTOM.equals(reason.dueTo().orElse(null));
return reason.dueTo().isPresent() && DueTo.CUSTOM.equals(reason.dueTo().get());
}

static boolean isRetryableQos(Response result) {
if (!isQosStatus(result)) {
return false;
}
QosReason reason = DialogueQosReasonDecoder.parse(result);
return !RetryHint.DO_NOT_RETRY.equals(reason.retryHint().orElse(null));
return reason.retryHint().isEmpty()
|| !RetryHint.DO_NOT_RETRY.equals(reason.retryHint().get());
}

static boolean isServerErrorRange(Response response) {
Expand Down

0 comments on commit 4a27098

Please sign in to comment.