Search in sources :

Example 1 with ServiceConfigurationFactory

use of com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory in project conjure-java-runtime by palantir.

the class ServiceConfigTest method testResource.

@Test
public void testResource() {
    ServiceConfigurationFactory factory = ServiceConfigurationFactory.of(rule.getConfiguration().getServiceDiscoveryConfiguration());
    TestService full = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), ClientConfigurations.of(factory.get("full")));
    TestService minimal = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), ClientConfigurations.of(factory.get("minimal")));
    assertThat(full.string()).isEqualTo("string");
    assertThat(minimal.string()).isEqualTo("string");
}
Also used : TestService(com.palantir.conjure.java.client.jaxrs.TestService) ServiceConfigurationFactory(com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Example 2 with ServiceConfigurationFactory

use of com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory in project dialogue by palantir.

the class RefreshingChannelFactory method create.

/**
 * Returns a refreshing {@link Channel} for a service identified by {@code service} in
 * {@link ServicesConfigBlock#services()}.
 */
public Channel create(String service) {
    return RefreshingChannel.create(conf, servicesConfigBlock -> {
        ServiceConfigurationFactory factory = ServiceConfigurationFactory.of(servicesConfigBlock);
        if (!factory.isEnabled(service)) {
            return new AlwaysThrowingChannel(service);
        }
        ServiceConfiguration serviceConfiguration = factory.get(service);
        ClientConfiguration clientConfiguration = ClientConfigurations.of(serviceConfiguration);
        Channel channel = channelFactory.create(clientConfiguration);
        return channel;
    });
}
Also used : ServiceConfiguration(com.palantir.conjure.java.api.config.service.ServiceConfiguration) Channel(com.palantir.dialogue.Channel) EndpointChannel(com.palantir.dialogue.EndpointChannel) ServiceConfigurationFactory(com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory) ClientConfiguration(com.palantir.conjure.java.client.config.ClientConfiguration)

Aggregations

ServiceConfigurationFactory (com.palantir.conjure.java.api.config.service.ServiceConfigurationFactory)2 ServiceConfiguration (com.palantir.conjure.java.api.config.service.ServiceConfiguration)1 ClientConfiguration (com.palantir.conjure.java.client.config.ClientConfiguration)1 TestService (com.palantir.conjure.java.client.jaxrs.TestService)1 HostMetricsRegistry (com.palantir.conjure.java.okhttp.HostMetricsRegistry)1 Channel (com.palantir.dialogue.Channel)1 EndpointChannel (com.palantir.dialogue.EndpointChannel)1 Test (org.junit.Test)1