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());
}
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());
}
}
}
Aggregations