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