use of com.palantir.conjure.java.api.config.service.PartialServiceConfiguration in project atlasdb by palantir.
the class DialogueClientOptionsTest method serviceConfigBlockGeneration.
@Test
public void serviceConfigBlockGeneration() {
ServicesConfigBlock servicesConfigBlock = DialogueClientOptions.toServicesConfigBlock(ImmutableMap.of(SERVICE_NAME, REMOTE_SERVICE_CONFIGURATION_EXTENDED_TIMEOUT));
assertThat(servicesConfigBlock.services()).containsOnlyKeys(SERVICE_NAME);
PartialServiceConfiguration partialServiceConfiguration = servicesConfigBlock.services().get(SERVICE_NAME);
assertThat(partialServiceConfiguration.uris()).hasSameElementsAs(SERVERS);
assertThat(partialServiceConfiguration.security()).contains(SSL_CONFIGURATION);
assertThat(partialServiceConfiguration.proxyConfiguration()).isEmpty();
assertThat(partialServiceConfiguration.backoffSlotSize()).contains(ClientOptionsConstants.STANDARD_BACKOFF_SLOT_SIZE);
assertThat(partialServiceConfiguration.connectTimeout()).contains(ClientOptionsConstants.CONNECT_TIMEOUT);
assertThat(partialServiceConfiguration.maxNumRetries()).contains(ClientOptionsConstants.STANDARD_MAX_RETRIES);
assertThat(partialServiceConfiguration.readTimeout()).contains(ClientOptionsConstants.LONG_READ_TIMEOUT);
}
use of com.palantir.conjure.java.api.config.service.PartialServiceConfiguration in project atlasdb by palantir.
the class DialogueClientOptionsTest method differentlyKeyedServicesTreatedDifferently.
@Test
public void differentlyKeyedServicesTreatedDifferently() {
String otherServiceName = "tom";
ServicesConfigBlock servicesConfigBlock = DialogueClientOptions.toServicesConfigBlock(ImmutableMap.of(SERVICE_NAME, REMOTE_SERVICE_CONFIGURATION_EXTENDED_TIMEOUT, otherServiceName, REMOTE_SERVICE_CONFIGURATION_SHORT_TIMEOUT));
assertThat(servicesConfigBlock.services()).containsOnlyKeys(SERVICE_NAME, otherServiceName);
PartialServiceConfiguration partialServiceConfiguration = servicesConfigBlock.services().get(SERVICE_NAME);
assertThat(partialServiceConfiguration.readTimeout()).contains(ClientOptionsConstants.LONG_READ_TIMEOUT);
assertThat(partialServiceConfiguration.writeTimeout()).contains(ClientOptionsConstants.LONG_READ_TIMEOUT);
PartialServiceConfiguration otherPartialServiceConfiguration = servicesConfigBlock.services().get(otherServiceName);
assertThat(otherPartialServiceConfiguration.readTimeout()).contains(ClientOptionsConstants.SHORT_READ_TIMEOUT);
assertThat(otherPartialServiceConfiguration.writeTimeout()).contains(ClientOptionsConstants.SHORT_READ_TIMEOUT);
}
use of com.palantir.conjure.java.api.config.service.PartialServiceConfiguration in project dialogue by palantir.
the class ReloadingClientFactory method getInternalDialogueChannel.
private Refreshable<InternalDialogueChannel> getInternalDialogueChannel(String serviceName) {
Preconditions.checkNotNull(serviceName, "serviceName");
String channelName = ChannelNames.reloading(serviceName, params);
return params.scb().map(block -> {
Preconditions.checkNotNull(block, "Refreshable must not provide a null ServicesConfigBlock");
if (!block.services().containsKey(serviceName)) {
return new EmptyInternalDialogueChannel(() -> new SafeIllegalStateException("Service not configured (config block not present)", SafeArg.of("serviceName", serviceName), SafeArg.of("available", block.services().keySet())));
}
if (block.services().get(serviceName).uris().isEmpty()) {
return new EmptyInternalDialogueChannel(() -> {
Map<String, PartialServiceConfiguration> servicesWithUris = Maps.filterValues(block.services(), c -> !c.uris().isEmpty());
return new SafeIllegalStateException("Service not configured (no URIs)", SafeArg.of("serviceName", serviceName), SafeArg.of("available", servicesWithUris.keySet()));
});
}
ServiceConfiguration serviceConf = ServiceConfigurationFactory.of(block).get(serviceName);
DialogueChannel dialogueChannel = cache.getNonReloadingChannel(params, serviceConf, channelName, OptionalInt.empty());
return new InternalDialogueChannelFromDialogueChannel(dialogueChannel);
});
}
Aggregations