Search in sources :

Example 1 with ClientOptions

use of com.netflix.ribbon.ClientOptions in project ribbon by Netflix.

the class TemplateBuilderTest method testHystrixProperties.

@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());
}
Also used : ClientOptions(com.netflix.ribbon.ClientOptions) HystrixCommandProperties(com.netflix.hystrix.HystrixCommandProperties) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with ClientOptions

use of com.netflix.ribbon.ClientOptions in project ribbon by Netflix.

the class ClientPropertiesProcessor method process.

@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());
        }
    }
}
Also used : ClientOptions(com.netflix.ribbon.ClientOptions) ClientProperties(com.netflix.ribbon.proxy.annotation.ClientProperties) IClientConfig(com.netflix.client.config.IClientConfig) Property(com.netflix.ribbon.proxy.annotation.ClientProperties.Property)

Aggregations

ClientOptions (com.netflix.ribbon.ClientOptions)2 IClientConfig (com.netflix.client.config.IClientConfig)1 HystrixCommandProperties (com.netflix.hystrix.HystrixCommandProperties)1 ClientProperties (com.netflix.ribbon.proxy.annotation.ClientProperties)1 Property (com.netflix.ribbon.proxy.annotation.ClientProperties.Property)1 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1