Making Hystrix + Feign opt in

without this change we allways force Feign to use Hystrix
with this change you need to pass the `feign.hystrix.enabled=true` flag to turn it on

fixes #627
This commit is contained in:
Marcin Grzejszczak
2017-07-03 08:00:40 +02:00
parent c3e90e4e21
commit 2a09be747d
2 changed files with 14 additions and 15 deletions

View File

@@ -53,7 +53,7 @@ public class TraceFeignClientAutoConfiguration {
@Bean
@Scope("prototype")
@ConditionalOnClass(name = {"com.netflix.hystrix.HystrixCommand", "feign.hystrix.HystrixFeign"})
@ConditionalOnProperty(name = "feign.hystrix.enabled", matchIfMissing = true)
@ConditionalOnProperty(name = "feign.hystrix.enabled", havingValue = "true")
Feign.Builder feignHystrixBuilder(BeanFactory beanFactory) {
return SleuthHystrixFeignBuilder.builder(beanFactory);
}
@@ -61,7 +61,7 @@ public class TraceFeignClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@Scope("prototype")
@ConditionalOnProperty(name = "feign.hystrix.enabled", havingValue = "false")
@ConditionalOnProperty(name = "feign.hystrix.enabled", havingValue = "false", matchIfMissing = true)
Feign.Builder feignBuilder(BeanFactory beanFactory) {
return SleuthFeignBuilder.builder(beanFactory);
}

View File

@@ -16,10 +16,13 @@
package org.springframework.cloud.sleuth.instrument.web.client.feign.servererrors;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.jayway.awaitility.Awaitility;
import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import feign.codec.Decoder;
import feign.codec.ErrorDecoder;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -54,14 +57,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.jayway.awaitility.Awaitility;
import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import feign.codec.Decoder;
import feign.codec.ErrorDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -72,7 +70,8 @@ import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = FeignClientServerErrorTests.TestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { "spring.application.name=fooservice" })
@TestPropertySource(properties = { "spring.application.name=fooservice" ,
"feign.hystrix.enabled=true"})
public class FeignClientServerErrorTests {
@Autowired TestFeignInterface feignInterface;