janhoy commented on code in PR #1871: URL: https://github.com/apache/solr/pull/1871#discussion_r1316882036
########## solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreaker.java: ########## @@ -52,4 +62,48 @@ public CircuitBreaker() {} /** Get error message when the circuit breaker triggers */ public abstract String getErrorMessage(); + + /** + * Set the request types for which this circuit breaker should be checked. If not called, the + * circuit breaker will be checked for the {@link SolrRequestType#QUERY} request type only. + * + * @param requestTypes list of strings representing request types + * @throws IllegalArgumentException if the request type is not valid + */ + public void setRequestTypes(List<String> requestTypes) { + this.requestTypes = + requestTypes.stream() + .map(t -> SolrRequestType.valueOf(t.toUpperCase(Locale.ROOT))) + .peek( + t -> { + if (!SUPPORTED_TYPES.contains(t)) { + throw new IllegalArgumentException( + String.format( + Locale.ROOT, + "Request type %s is not supported for circuit breakers", + t.name())); + } + }) + .collect(Collectors.toSet()); + } + + public Set<SolrRequestType> getRequestTypes() { + return requestTypes; + } + + /** + * Return the proper error code to use in exception. For legacy use of {@link CircuitBreaker} we + * return 503 for backward compatibility, else return 429. + * + * @deprecated Remove in 10.0 + */ + @Deprecated(since = "9.4") + public static SolrException.ErrorCode getErrorCode(List<CircuitBreaker> trippedCircuitBreakers) { + if (trippedCircuitBreakers != null + && trippedCircuitBreakers.stream().anyMatch(cb -> cb instanceof CircuitBreakerManager)) { Review Comment: I think we can defer this, as the user will have a workaround, to switch to the pluggable CBs. We can document this fact in refguide (other issue). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org