当前位置: 首页>>代码示例>>Java>>正文


Java HystrixFeign.Builder方法代码示例

本文整理汇总了Java中feign.hystrix.HystrixFeign.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixFeign.Builder方法的具体用法?Java HystrixFeign.Builder怎么用?Java HystrixFeign.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在feign.hystrix.HystrixFeign的用法示例。


在下文中一共展示了HystrixFeign.Builder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: targetWithFallbackFactory

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
private <T> T targetWithFallbackFactory(String feignClientName, FeignContext context,
										Target.HardCodedTarget<T> target,
										HystrixFeign.Builder builder,
										Class<?> fallbackFactoryClass) {
	FallbackFactory<? extends T> fallbackFactory = (FallbackFactory<? extends T>)
		getFromContext("fallbackFactory", feignClientName, context, fallbackFactoryClass, FallbackFactory.class);
	/* We take a sample fallback from the fallback factory to check if it returns a fallback
	that is compatible with the annotated feign interface. */
	Object exampleFallback = fallbackFactory.create(new RuntimeException());
	Assert.notNull(exampleFallback,
		String.format(
		"Incompatible fallbackFactory instance for feign client %s. Factory may not produce null!",
			feignClientName));
	/*if (!target.type().isAssignableFrom(exampleFallback.getClass())) {
		throw new IllegalStateException(
			String.format(
				"Incompatible fallbackFactory instance for feign client %s. Factory produces instances of '%s', but should produce instances of '%s'",
				feignClientName, exampleFallback.getClass(), target.type()));
	}*/
	return builder.target(target, fallbackFactory);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:22,代码来源:EnhanceHystrixTargeter.java

示例2: targetWithFallbackFactory

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
private <T> T targetWithFallbackFactory(String feignClientName, FeignContext context,
										Target.HardCodedTarget<T> target,
										HystrixFeign.Builder builder,
										Class<?> fallbackFactoryClass) {
	FallbackFactory<? extends T> fallbackFactory = (FallbackFactory<? extends T>)
		getFromContext("fallbackFactory", feignClientName, context, fallbackFactoryClass, FallbackFactory.class);
	/* We take a sample fallback from the fallback factory to check if it returns a fallback
	that is compatible with the annotated feign interface. */
	Object exampleFallback = fallbackFactory.create(new RuntimeException());
	Assert.notNull(exampleFallback,
		String.format(
		"Incompatible fallbackFactory instance for feign client %s. Factory may not produce null!",
			feignClientName));
	if (!target.type().isAssignableFrom(exampleFallback.getClass())) {
		throw new IllegalStateException(
			String.format(
				"Incompatible fallbackFactory instance for feign client %s. Factory produces instances of '%s', but should produce instances of '%s'",
				feignClientName, exampleFallback.getClass(), target.type()));
	}
	return builder.target(target, fallbackFactory);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:22,代码来源:HystrixTargeter.java

示例3: simpleFeignBuilder

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
public static HystrixFeign.Builder simpleFeignBuilder() {
    JacksonDecoder decoder = new JacksonDecoder(defaultObjectMapper);
    return HystrixFeign.builder()
            .setterFactory(new DefaultSetterFactory())
            .logger(new Slf4jLogger())
            .logLevel(Logger.Level.FULL)
            .retryer(new Retryer.Default())
            .contract(new Contract.Default())
            .client(new OkHttpClient())
            .options(new Request.Options())
            .encoder(new JacksonEncoder(defaultObjectMapper))
            .decoder(decoder)
            .errorDecoder(new AccessApiErrorDecoder(decoder));
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:15,代码来源:Clients.java

示例4: client

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
protected HystrixFeign.Builder client() {
  return HystrixFeign.builder().logger(new Slf4jLogger()).retryer(new Retryer.Default())
      .logLevel(Logger.Level.FULL);
}
 
开发者ID:januslabs,项目名称:consul-ribbon-starter,代码行数:5,代码来源:RibbonFeignClientConfig.java

示例5: jaxbclient

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
protected HystrixFeign.Builder jaxbclient() {
  return HystrixFeign.builder().encoder(new JAXBEncoder(new JAXBContextFactory.Builder().build()))
      .decoder(new JAXBDecoder(new JAXBContextFactory.Builder().build()))
      .logger(new Slf4jLogger()).retryer(new Retryer.Default()).logLevel(Logger.Level.FULL);
}
 
开发者ID:januslabs,项目名称:consul-ribbon-starter,代码行数:6,代码来源:RibbonFeignClientConfig.java

示例6: jsonclient

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
protected HystrixFeign.Builder jsonclient() {
  return HystrixFeign.builder().encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
      .logger(new Slf4jLogger()).retryer(new Retryer.Default()).logLevel(Logger.Level.FULL);
}
 
开发者ID:januslabs,项目名称:consul-ribbon-starter,代码行数:5,代码来源:RibbonFeignClientConfig.java

示例7: targetWithFallback

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
private <T> T targetWithFallback(String feignClientName, FeignContext context,
								 Target.HardCodedTarget<T> target,
								 HystrixFeign.Builder builder, Class<?> fallback) {
	T fallbackInstance = getFromContext("fallback", feignClientName, context, fallback, target.type());
	return builder.target(target, fallbackInstance);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:7,代码来源:EnhanceHystrixTargeter.java

示例8: newHystrixFeignClientBuilder

import feign.hystrix.HystrixFeign; //导入方法依赖的package包/类
public HystrixFeign.Builder newHystrixFeignClientBuilder() {
    return HystrixFeign.builder()
            .encoder(encoder)
            .decoder(decoder);
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:6,代码来源:MSF4JClient.java


注:本文中的feign.hystrix.HystrixFeign.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。