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


Java ClientOptions类代码示例

本文整理汇总了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());
        }
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:ClientPropertiesProcessor.java

示例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());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:20,代码来源:TemplateBuilderTest.java

示例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);
}
 
开发者ID:diegopacheco,项目名称:Building_Effective_Microservices,代码行数:11,代码来源:RibbonMeetupClient.java

示例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);
}
 
开发者ID:diegopacheco,项目名称:Building_Effective_Microservices,代码行数:11,代码来源:RibbonMeetupClient.java

示例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;
}
 
开发者ID:jscattergood,项目名称:WeatherAlarm,代码行数:11,代码来源:YahooWeatherQueryHandler.java

示例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;
}
 
开发者ID:jscattergood,项目名称:WeatherAlarm,代码行数:11,代码来源:WUndergroundWeatherQueryHandler.java

示例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();
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:38,代码来源:RibbonModuleTest.java

示例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();
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:37,代码来源:RxMovieTemplateExample.java

示例9: withClientOptions

import com.netflix.ribbon.ClientOptions; //导入依赖的package包/类
@Override
public Builder withClientOptions(ClientOptions options) {
    this.clientOptions = options;
    return this;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:6,代码来源:HttpResourceGroup.java

示例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;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:6,代码来源:HttpResourceGroup.java


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