本文整理汇总了Java中com.netflix.ribbon.ClientOptions类的典型用法代码示例。如果您正苦于以下问题:Java ClientOptions类的具体用法?Java ClientOptions怎么用?Java ClientOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientOptions类属于com.netflix.ribbon包,在下文中一共展示了ClientOptions类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Override
public void process(String groupName, GroupBuilder groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass) {
ClientProperties properties = interfaceClass.getAnnotation(ClientProperties.class);
if (properties != null) {
IClientConfig config = resourceFactory.getClientConfigFactory().newConfig();
for (Property prop : properties.properties()) {
String name = prop.name();
config.set(CommonClientConfigKey.valueOf(name), prop.value());
}
ClientOptions options = ClientOptions.from(config);
groupBuilder.withClientOptions(options);
if (properties.exportToArchaius()) {
exportPropertiesToArchaius(groupName, config, interfaceClass.getName());
}
}
}
示例2: testHystrixProperties
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Test
public void testHystrixProperties() {
ClientOptions clientOptions = ClientOptions.create()
.withMaxAutoRetriesNextServer(1)
.withMaxAutoRetries(1)
.withConnectTimeout(1000)
.withMaxTotalConnections(400)
.withReadTimeout(2000);
HttpResourceGroup group = Ribbon.createHttpResourceGroup("test", clientOptions);
HttpRequestTemplate<ByteBuf> template = group.newTemplateBuilder("testHystrixProperties", ByteBuf.class)
.withMethod("GET")
.withUriTemplate("/foo/bar").build();
HttpRequest<ByteBuf> request = (HttpRequest<ByteBuf>) template
.requestBuilder().build();
HystrixObservableCommandChain<ByteBuf> hystrixCommandChain = request.createHystrixCommandChain();
HystrixCommandProperties props = hystrixCommandChain.getCommands().get(0).getProperties();
assertEquals(400, props.executionIsolationSemaphoreMaxConcurrentRequests().get().intValue());
assertEquals(12000, props.executionIsolationThreadTimeoutInMilliseconds().get().intValue());
}
示例3: listByType
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
public Observable<MeetupsByType> listByType(String type) {
HttpResourceGroup httpRG = Ribbon.createHttpResourceGroup("apiGroup", ClientOptions.create()
.withMaxAutoRetriesNextServer(1).withConfigurationBasedServerList(getServerIP("microservice")));
HttpRequestTemplate<ByteBuf> apiTemplate = httpRG.newTemplateBuilder("apiCall", ByteBuf.class).withMethod("GET")
.withUriTemplate("/meetup?type=" + type).withFallbackProvider(new DefaultFallback())
.withResponseValidator(new SimpleResponseValidator()).build();
return execute(MeetupsByType.class,apiTemplate);
}
示例4: createMeetup
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
public Observable<Boolean> createMeetup(String name, String type) {
HttpResourceGroup httpRG = Ribbon.createHttpResourceGroup("apiGroup", ClientOptions.create()
.withMaxAutoRetriesNextServer(1).withConfigurationBasedServerList(getServerIP("microservice")));
HttpRequestTemplate<ByteBuf> apiTemplate = httpRG.newTemplateBuilder("apiCall", ByteBuf.class).withMethod("PUT")
.withUriTemplate("/meetup?type=" + type + "&name=" + name).withFallbackProvider(new DefaultFallback())
.withResponseValidator(new SimpleResponseValidator()).build();
return execute(Boolean.class,apiTemplate);
}
示例5: getResourceGroup
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Override
protected HttpResourceGroup getResourceGroup() {
if (cachedResourceGroup == null) {
cachedResourceGroup = Ribbon.createHttpResourceGroup("yahooWeatherService",
ClientOptions.create()
.withMaxAutoRetries(3)
.withConfigurationBasedServerList("query.yahooapis.com"));
}
return cachedResourceGroup;
}
示例6: getResourceGroup
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Override
protected HttpResourceGroup getResourceGroup() {
if (cachedResourceGroup == null) {
cachedResourceGroup = Ribbon.createHttpResourceGroup("wundergroundWeatherService",
ClientOptions.create()
.withMaxAutoRetries(3)
.withConfigurationBasedServerList("api.wunderground.com"));
}
return cachedResourceGroup;
}
示例7: MyService
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Inject
public MyService(RibbonResourceFactory factory) {
httpResourceGroup = factory.createHttpResourceGroup("movieServiceClient",
ClientOptions.create()
.withMaxAutoRetriesNextServer(3)
.withConfigurationBasedServerList("localhost:" + PORT));
registerMovieTemplate = httpResourceGroup.newTemplateBuilder("registerMovie", ByteBuf.class)
.withMethod("POST")
.withUriTemplate("/movies")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
updateRecommendationTemplate = httpResourceGroup.newTemplateBuilder("updateRecommendation", ByteBuf.class)
.withMethod("POST")
.withUriTemplate("/users/{userId}/recommendations")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
recommendationsByUserIdTemplate = httpResourceGroup.newTemplateBuilder("recommendationsByUserId", ByteBuf.class)
.withMethod("GET")
.withUriTemplate("/users/{userId}/recommendations")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withFallbackProvider(new RecommendationServiceFallbackHandler())
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
recommendationsByTemplate = httpResourceGroup.newTemplateBuilder("recommendationsBy", ByteBuf.class)
.withMethod("GET")
.withUriTemplate("/recommendations?category={category}&ageGroup={ageGroup}")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withFallbackProvider(new RecommendationServiceFallbackHandler())
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
}
示例8: RxMovieTemplateExample
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
public RxMovieTemplateExample(int port) {
httpResourceGroup = Ribbon.createHttpResourceGroup("movieServiceClient",
ClientOptions.create()
.withMaxAutoRetriesNextServer(3)
.withConfigurationBasedServerList("localhost:" + port));
registerMovieTemplate = httpResourceGroup.newTemplateBuilder("registerMovie", ByteBuf.class)
.withMethod("POST")
.withUriTemplate("/movies")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
updateRecommendationTemplate = httpResourceGroup.newTemplateBuilder("updateRecommendation", ByteBuf.class)
.withMethod("POST")
.withUriTemplate("/users/{userId}/recommendations")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
recommendationsByUserIdTemplate = httpResourceGroup.newTemplateBuilder("recommendationsByUserId", ByteBuf.class)
.withMethod("GET")
.withUriTemplate("/users/{userId}/recommendations")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withFallbackProvider(new RecommendationServiceFallbackHandler())
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
recommendationsByTemplate = httpResourceGroup.newTemplateBuilder("recommendationsBy", ByteBuf.class)
.withMethod("GET")
.withUriTemplate("/recommendations?category={category}&ageGroup={ageGroup}")
.withHeader("X-Platform-Version", "xyz")
.withHeader("X-Auth-Token", "abc")
.withFallbackProvider(new RecommendationServiceFallbackHandler())
.withResponseValidator(new RecommendationServiceResponseValidator()).build();
}
示例9: withClientOptions
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Override
public Builder withClientOptions(ClientOptions options) {
this.clientOptions = options;
return this;
}
示例10: HttpResourceGroup
import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
protected HttpResourceGroup(String groupName) {
super(groupName, ClientOptions.create(), ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT);
client = transportFactory.newHttpClient(getClientConfig());
headers = HttpHeaders.EMPTY_HEADERS;
}