當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。