use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.
the class RequestConfigProviderImpl method createDefaultConfig.
/**
* Default configuration map must specify default values for all properties.
*/
private static ParSeqRestliClientConfig createDefaultConfig() {
ParSeqRestliClientConfigBuilder builder = new ParSeqRestliClientConfigBuilder();
builder.addTimeoutMs("*.*/*.*", DEFAULT_TIMEOUT);
builder.addBatchingEnabled("*.*/*.*", DEFAULT_BATCHING_ENABLED);
builder.addMaxBatchSize("*.*/*.*", DEFAULT_MAX_BATCH_SIZE);
return builder.build();
}
use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.
the class TestRequestConfigProvider method testOutboundName.
@Test
public void testOutboundName() throws RequestConfigKeyParsingException {
ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
configBuilder.addTimeoutMs("*.*/greetings.*", 1000L);
configBuilder.addTimeoutMs("*.*/associations:foo.*", 1001L);
configBuilder.addTimeoutMs("*.*/associations.*", 1000L);
RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), () -> Optional.empty());
RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
rc = provider.apply(new GroupsBuilders().get().id(10).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(DEFAULT_TIMEOUT));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
rc = provider.apply(new AssociationsSubBuilders().get().srcKey("a").destKey("b").id("x").build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.
the class TestRequestConfigProvider method testOutboundOp.
@Test
public void testOutboundOp() throws RequestConfigKeyParsingException {
ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
configBuilder.addTimeoutMs("*.*/*.GET", 1000L);
RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), () -> Optional.empty());
RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
rc = provider.apply(new GreetingsBuilders().delete().id(0L).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(DEFAULT_TIMEOUT));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
rc = provider.apply(new AssociationsSubBuilders().get().srcKey("a").destKey("b").id("x").build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.
the class TestRequestConfigProvider method testPrioritiesWithInboundSubresourceAndOutboundMatch.
@Test
public void testPrioritiesWithInboundSubresourceAndOutboundMatch() throws RequestConfigKeyParsingException {
ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
configBuilder.addTimeoutMs("*.*/*.GET", 1000L);
configBuilder.addTimeoutMs("x.GET/*.GET", 1000L);
configBuilder.addTimeoutMs("y.GET/x1.GET", 1000L);
configBuilder.addTimeoutMs("y.GET/x2.GET", 1000L);
configBuilder.addTimeoutMs("*.GET/x.GET", 1000L);
configBuilder.addTimeoutMs("*.GET/x2.GET", 1000L);
configBuilder.addTimeoutMs("*.GET/greetings.GET", 1000L);
configBuilder.addTimeoutMs("greetings.GET/*.GET", 1000L);
configBuilder.addTimeoutMs("greetings.GET/greetings.GET", 100L);
configBuilder.addTimeoutMs("*.*/greetings.DELETE", 1000L);
configBuilder.addTimeoutMs("greetings.*/greetings.DELETE", 1000L);
configBuilder.addTimeoutMs("*.GET/greetings.DELETE", 1000L);
configBuilder.addTimeoutMs("greetings.GET/greetings.DELETE", 500L);
RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), requestContextFinder("greetings:associationsSub", ResourceMethod.GET.toString().toUpperCase(), Optional.empty(), Optional.empty()));
RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(100L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
rc = provider.apply(new GreetingsBuilders().delete().id(0L).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(500L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.
the class TestRequestConfigProvider method testFromEmptyMapOverrideDefault.
@Test
public void testFromEmptyMapOverrideDefault() throws RequestConfigKeyParsingException {
ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
configBuilder.addTimeoutMs("*.*/*.*", 1000L);
configBuilder.addMaxBatchSize("*.*/*.*", 4096);
configBuilder.addBatchingEnabled("*.*/*.*", true);
RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), () -> Optional.empty());
RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(true));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(4096));
rc = provider.apply(new AssociationsSubBuilders().get().srcKey("a").destKey("b").id("x").build());
assertNotNull(rc);
assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(true));
assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(4096));
}
Aggregations