Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.cloud.gateway.filter.factory;

import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -41,7 +42,6 @@
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.util.UriComponentsBuilder;

import static java.util.Collections.singletonList;
import static org.springframework.cloud.gateway.support.GatewayToStringStyler.filterToStringCreator;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
Expand All @@ -58,6 +58,26 @@ public abstract class SpringCloudCircuitBreakerFilterFactory
/** CircuitBreaker component name. */
public static final String NAME = "CircuitBreaker";

/**
* Fallback uri key.
*/
public static final String FALLBACK_URI_KEY = "fallbackUri";

/**
* Route Id key.
*/
public static final String ROUTE_ID_KEY = "routeId";

/**
* Status codes key.
*/
public static final String STATUS_CODES_KEY = "statusCodes";

/**
* Resume without error key.
*/
public static final String RESUME_WITHOUT_ERROR_KEY = "resumeWithoutError";

private ReactiveCircuitBreakerFactory reactiveCircuitBreakerFactory;

private ReactiveCircuitBreaker cb;
Expand All @@ -84,7 +104,7 @@ private DispatcherHandler getDispatcherHandler() {

@Override
public List<String> shortcutFieldOrder() {
return singletonList(NAME_KEY);
return Arrays.asList(NAME_KEY, FALLBACK_URI_KEY, ROUTE_ID_KEY, STATUS_CODES_KEY, RESUME_WITHOUT_ERROR_KEY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work. RouteId should be set dynamically, not by a usewr. status codes is a set. I think if you need all these things, you shouldn't use the shortcut.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Spencer,

Thank you for the feedback. Based on your points, it makes sense to exclude routeId from the shortcutFieldOrder() method since it should indeed be set dynamically and not by the user configuration.

To align with this, I suggest the following adjustment to only include parameters suitable for shortcut usage and remove the routeId

@Override
public List<String> shortcutFieldOrder() {
    return Arrays.asList(NAME_KEY, FALLBACK_URI_KEY, STATUS_CODES_KEY, RESUME_WITHOUT_ERROR_KEY);
}

That would work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, statusCodes is a set and will not work in combination with others as a shortcut.

}

@Override
Expand Down
Loading