Category : feign

Order This article mainly studies FeignLoadBalancer of spring cloud. FeignLoadBalancer spring-cloud-openfeign-core-2.2.0.M1-sources.jar! /org/springframework/cloud/openfeign/ribbon/FeignLoadBalancer.java public class FeignLoadBalancer extends AbstractLoadBalancerAwareClient<FeignLoadBalancer.RibbonRequest, FeignLoadBalancer.RibbonResponse> { private final RibbonProperties ribbon; protected int connectTimeout; protected int readTimeout; protected IClientConfig clientConfig; protected ServerIntrospector serverIntrospector; public FeignLoadBalancer(ILoadBalancer lb, IClientConfig clientConfig, ServerIntrospector serverIntrospector) { super(lb, clientConfig); this.setRetryHandler(RetryHandler.DEFAULT); this.clientConfig = clientConfig; this.ribbon = RibbonProperties.from(clientConfig); RibbonProperties ribbon = ..

Read more

Order This article mainly studies spring cloud’s RetryableFeignLoadBalancer. RetryableFeignLoadBalancer spring-cloud-openfeign-core-2.2.0.M1-sources.jar! /org/springframework/cloud/openfeign/ribbon/RetryableFeignLoadBalancer.java public class RetryableFeignLoadBalancer extends FeignLoadBalancer implements ServiceInstanceChooser { private final LoadBalancedRetryFactory loadBalancedRetryFactory; public RetryableFeignLoadBalancer(ILoadBalancer lb, IClientConfig clientConfig, ServerIntrospector serverIntrospector, LoadBalancedRetryFactory loadBalancedRetryFactory) { super(lb, clientConfig, serverIntrospector); this.loadBalancedRetryFactory = loadBalancedRetryFactory; this.setRetryHandler(new DefaultLoadBalancerRetryHandler(clientConfig)); } @Override public RibbonResponse execute(final RibbonRequest request, IClientConfig configOverride) throws IOException { final Request.Options ..

Read more

Order This article mainly studies FeignClientBuilder of spring cloud. FeignClientBuilder spring-cloud-openfeign-core-2.2.0.M1-sources.jar! /org/springframework/cloud/openfeign/FeignClientBuilder.java public class FeignClientBuilder { private final ApplicationContext applicationContext; public FeignClientBuilder(final ApplicationContext applicationContext) { this.applicationContext = applicationContext; } public <T> Builder<T> forType(final Class<T> type, final String name) { return new Builder<>(this.applicationContext, type, name); } /** * Builder of feign targets. * * @param <T> ..

Read more

Order This article mainly studies the FeignClientFactoryBean of spring cloud. FeignClientFactoryBean spring-cloud-openfeign-core-2.2.0.M1-sources.jar! /org/springframework/cloud/openfeign/FeignClientFactoryBean.java class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean, ApplicationContextAware { /*********************************** * WARNING! Nothing in this class should be @Autowired. It causes NPEs because of some * lifecycle race condition. ***********************************/ private Class<?> type; private String name; private String url; private String contextId; private String ..

Read more

Order This article mainly studies feign’s RequestInterceptor RequestInterceptor feign-core-10.2.3-sources.jar! /feign/RequestInterceptor.java public interface RequestInterceptor { /** * Called for every request. Add data using methods on the supplied {@link RequestTemplate}. */ void apply(RequestTemplate template); } The RequestInterceptor interface defines the apply method, and its parameter is RequestTemplateï¼› ; It has an abstract class called BaseRequestInterceptor, and ..

Read more

Order This article mainly studies feign’s Retryer. Retryer feign-core-10.2.3-sources.jar! /feign/Retryer.java public interface Retryer extends Cloneable { /** * if retry is permitted, return (possibly after sleeping). Otherwise propagate the exception. */ void continueOrPropagate(RetryableException e); Retryer clone(); class Default implements Retryer { private final int maxAttempts; private final long period; private final long maxPeriod; int attempt; ..

Read more

Order This article mainly studies the Targeter of spring cloud openfeign. Targeter spring-cloud-openfeign-core-2.2.0.M1-sources.jar! /org/springframework/cloud/openfeign/Targeter.java interface Targeter { <T> T target(FeignClientFactoryBean factory, Feign.Builder feign, FeignContext context, Target.HardCodedTarget<T> target); } Targeter defines a target method that receives parameters of type FeignClientFactoryBean, Feign.Builder, FeignContext, Target.HardCodedTarget DefaultTargeter spring-cloud-openfeign-core-2.2.0.M1-sources.jar! /org/springframework/cloud/openfeign/DefaultTargeter.java class DefaultTargeter implements Targeter { @Override public <T> T target(FeignClientFactoryBean ..

Read more

Order This article mainly studies feign’s HystrixInvocationHandler HystrixInvocationHandler feign-hystrix-10.2.3-sources.jar! /feign/hystrix/HystrixInvocationHandler.java final class HystrixInvocationHandler implements InvocationHandler { private final Target<?> target; private final Map<Method, MethodHandler> dispatch; private final FallbackFactory<?> fallbackFactory; // Nullable private final Map<Method, Method> fallbackMethodMap; private final Map<Method, Setter> setterMethodMap; HystrixInvocationHandler(Target<?> target, Map<Method, MethodHandler> dispatch, SetterFactory setterFactory, FallbackFactory<?> fallbackFactory) { this.target = checkNotNull(target, “target”); ..

Read more

Order This article mainly studies feign’s Contract Contract feign-core-10.2.3-sources.jar! /feign/Contract.java public interface Contract { /** * Called to parse the methods in the class that are linked to HTTP requests. * * @param targetType {@link feign.Target#type() type} of the Feign interface. */ // TODO: break this and correct spelling at some point List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType); ..

Read more