Search in sources :

Example 1 with PartialServiceConfiguration

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);
}
Also used : ServicesConfigBlock(com.palantir.conjure.java.api.config.service.ServicesConfigBlock) PartialServiceConfiguration(com.palantir.conjure.java.api.config.service.PartialServiceConfiguration) Test(org.junit.Test)

Example 2 with PartialServiceConfiguration

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);
}
Also used : ServicesConfigBlock(com.palantir.conjure.java.api.config.service.ServicesConfigBlock) PartialServiceConfiguration(com.palantir.conjure.java.api.config.service.PartialServiceConfiguration) Test(org.junit.Test)

Example 3 with PartialServiceConfiguration

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);
    });
}
Also used : ServiceConfiguration(com.palantir.conjure.java.api.config.service.ServiceConfiguration) PartialServiceConfiguration(com.palantir.conjure.java.api.config.service.PartialServiceConfiguration) DialogueChannel(com.palantir.dialogue.core.DialogueChannel) PartialServiceConfiguration(com.palantir.conjure.java.api.config.service.PartialServiceConfiguration) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException)

Aggregations

PartialServiceConfiguration (com.palantir.conjure.java.api.config.service.PartialServiceConfiguration)3 ServicesConfigBlock (com.palantir.conjure.java.api.config.service.ServicesConfigBlock)2 Test (org.junit.Test)2 ServiceConfiguration (com.palantir.conjure.java.api.config.service.ServiceConfiguration)1 DialogueChannel (com.palantir.dialogue.core.DialogueChannel)1 SafeIllegalStateException (com.palantir.logsafe.exceptions.SafeIllegalStateException)1