Browse Source

Use Feign naming convention for circuit names. (#496)

Fixes gh-484.
pull/500/head
Olga Maciaszek-Sharma 4 years ago committed by GitHub
parent
commit
11fd7dc43e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      docs/src/main/asciidoc/_configprops.adoc
  2. 2
      docs/src/main/asciidoc/spring-cloud-openfeign.adoc
  3. 2
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreaker.java
  4. 9
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerInvocationHandler.java
  5. 4
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignEncoderProperties.java

2
docs/src/main/asciidoc/_configprops.adoc

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
|feign.compression.request.min-request-size | `2048` | The minimum threshold content size.
|feign.compression.response.enabled | `false` | Enables the response from Feign to be compressed.
|feign.compression.response.useGzipDecoder | `false` | Enables the default gzip decoder to be used.
|feign.encoder.charset-from-content-type | `false` |
|feign.encoder.charset-from-content-type | `false` | Indicates whether the charset should be derived from the {@code Content-Type} header.
|feign.httpclient.connection-timeout | `2000` |
|feign.httpclient.connection-timer-repeat | `3000` |
|feign.httpclient.disable-ssl-validation | `false` |

2
docs/src/main/asciidoc/spring-cloud-openfeign.adoc

@ -456,7 +456,7 @@ public class FooConfiguration { @@ -456,7 +456,7 @@ public class FooConfiguration {
}
----
The circuit breaker name follows this pattern `<feignClientName>_<calledMethod>`. When calling a `@FeignClient` with name `foo` and the called interface method is `bar` then the circuit breaker name will be `foo_bar`.
The circuit breaker name follows this pattern `<feignClientName>#<calledMethod>`. When calling a `@FeignClient` with name `foo` and the called interface method is `bar` then the circuit breaker name will be `foo_bar`.
[[spring-cloud-feign-circuitbreaker-fallback]]
=== Feign Spring Cloud CircuitBreaker Fallbacks

2
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreaker.java

@ -79,7 +79,7 @@ public final class FeignCircuitBreaker { @@ -79,7 +79,7 @@ public final class FeignCircuitBreaker {
public Feign build(final FallbackFactory<?> nullableFallbackFactory) {
super.invocationHandlerFactory(
(target, dispatch) -> new FeignCircuitBreakerInvocationHandler(
circuitBreakerFactory, feignClientName, target, dispatch,
circuitBreakerFactory, target, dispatch,
nullableFallbackFactory));
return super.build();
}

9
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignCircuitBreakerInvocationHandler.java

@ -24,6 +24,7 @@ import java.util.Map; @@ -24,6 +24,7 @@ import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import feign.Feign;
import feign.InvocationHandlerFactory;
import feign.Target;
@ -36,8 +37,6 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler { @@ -36,8 +37,6 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler {
private final CircuitBreakerFactory factory;
private final String feignClientName;
private final Target<?> target;
private final Map<Method, InvocationHandlerFactory.MethodHandler> dispatch;
@ -46,12 +45,10 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler { @@ -46,12 +45,10 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler {
private final Map<Method, Method> fallbackMethodMap;
FeignCircuitBreakerInvocationHandler(CircuitBreakerFactory factory,
String feignClientName, Target<?> target,
FeignCircuitBreakerInvocationHandler(CircuitBreakerFactory factory, Target<?> target,
Map<Method, InvocationHandlerFactory.MethodHandler> dispatch,
FallbackFactory<?> nullableFallbackFactory) {
this.factory = factory;
this.feignClientName = feignClientName;
this.target = checkNotNull(target, "target");
this.dispatch = checkNotNull(dispatch, "dispatch");
this.fallbackMethodMap = toFallbackMethod(dispatch);
@ -79,7 +76,7 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler { @@ -79,7 +76,7 @@ class FeignCircuitBreakerInvocationHandler implements InvocationHandler {
else if ("toString".equals(method.getName())) {
return toString();
}
String circuitName = this.feignClientName + "_" + method.getName();
String circuitName = Feign.configKey(target.type(), method);
CircuitBreaker circuitBreaker = this.factory.create(circuitName);
Supplier<Object> supplier = asSupplier(method, args);
if (this.nullableFallbackFactory != null) {

4
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/FeignEncoderProperties.java

@ -22,14 +22,14 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @@ -22,14 +22,14 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* Properties for {@link SpringEncoder}.
*
* @author Olga Maciaszek-Sharma
*
* @since 2.2.8
*/
@ConfigurationProperties("feign.encoder")
public class FeignEncoderProperties {
/**
* Indicates whether the charset should be derived from the {@code Content-Type} header.
* Indicates whether the charset should be derived from the {@code Content-Type}
* header.
*/
private boolean charsetFromContentType = false;

Loading…
Cancel
Save