This commit is contained in:
ChiaChin Ho 2023-07-17 21:37:57 -05:00 committed by GitHub
commit fce085825f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,12 @@ import com.twitter.search.earlybird.thrift.ThriftTweetSource;
/** Utility methods that work on EarlybirdResponses. */ /** Utility methods that work on EarlybirdResponses. */
public final class EarlybirdResponseUtil { public final class EarlybirdResponseUtil {
static private List<EarlybirdResponseCode> successfulResponseCodeList
= Arrays.asList(EarlybirdResponseCode.SUCCESS,
EarlybirdResponseCode.TIER_SKIPPED,
EarlybirdResponseCode.REQUEST_BLOCKED_ERROR);
private EarlybirdResponseUtil() { private EarlybirdResponseUtil() {
} }
@ -77,9 +83,7 @@ public final class EarlybirdResponseUtil {
* Returns if the response should be considered failed for purposes of stats and logging. * Returns if the response should be considered failed for purposes of stats and logging.
*/ */
public static boolean responseConsideredFailed(EarlybirdResponseCode code) { public static boolean responseConsideredFailed(EarlybirdResponseCode code) {
return code != EarlybirdResponseCode.SUCCESS return !successfulResponseCodeList.contains(code);
&& code != EarlybirdResponseCode.REQUEST_BLOCKED_ERROR
&& code != EarlybirdResponseCode.TIER_SKIPPED;
} }
/** /**
@ -171,9 +175,7 @@ public final class EarlybirdResponseUtil {
*/ */
public static boolean isSuccessfulResponse(EarlybirdResponse response) { public static boolean isSuccessfulResponse(EarlybirdResponse response) {
return response != null return response != null
&& (response.getResponseCode() == EarlybirdResponseCode.SUCCESS && successfulResponseCodeList.contains(response.getResponseCode());
|| response.getResponseCode() == EarlybirdResponseCode.TIER_SKIPPED
|| response.getResponseCode() == EarlybirdResponseCode.REQUEST_BLOCKED_ERROR);
} }
/** /**