use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.
the class AtlasDbEteServer method getRemoteTimeLockManagementService.
private TimeLockManagementService getRemoteTimeLockManagementService(Refreshable<ServerListConfig> serverListConfig, TaggedMetricRegistry taggedMetrics) {
UserAgent userAgent = UserAgent.of(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
DialogueClients.ReloadingFactory reloadingFactory = DialogueClients.create(Refreshable.only(ServicesConfigBlock.builder().build())).withUserAgent(userAgent);
AtlasDbDialogueServiceProvider dialogueServiceProvider = AtlasDbDialogueServiceProvider.create(serverListConfig, reloadingFactory, userAgent, taggedMetrics);
return dialogueServiceProvider.getTimeLockManagementService();
}
use of com.palantir.conjure.java.api.config.service.UserAgent in project conjure-java-runtime by palantir.
the class Retrofit2ClientBuilderTest method testUserAgent_augmentedByHttpRemotingAndServiceComponents.
@Test
public void testUserAgent_augmentedByHttpRemotingAndServiceComponents() throws Exception {
TestService service = Retrofit2Client.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(String.format("http://%s:%s/api/", server.getHostName().toUpperCase(), server.getPort())));
server.enqueue(new MockResponse().setBody("\"server\""));
service.get().execute();
RecordedRequest request = server.takeRequest();
String conjureVersion = OkHttpClients.class.getPackage().getImplementationVersion();
UserAgent expected = AGENT.addAgent(UserAgent.Agent.of("TestService", "0.0.0")).addAgent(UserAgent.Agent.of(UserAgents.CONJURE_AGENT_NAME, conjureVersion != null ? conjureVersion : "0.0.0"));
assertThat(request.getHeader("User-Agent")).isEqualTo(UserAgents.format(expected));
}
use of com.palantir.conjure.java.api.config.service.UserAgent in project conjure-java-runtime by palantir.
the class OkHttpClients method augmentUserAgent.
/**
* Adds informational {@link Agent}s to the given {@link UserAgent}, one for the conjure-java-runtime library and
* one for the given service class. Version strings are extracted from the packages'
* {@link Package#getImplementationVersion implementation version}, defaulting to 0.0.0 if no version can be found.
*/
private static UserAgent augmentUserAgent(UserAgent agent, Class<?> serviceClass) {
UserAgent augmentedAgent = agent;
String maybeServiceVersion = serviceClass.getPackage().getImplementationVersion();
augmentedAgent = augmentedAgent.addAgent(UserAgent.Agent.of(serviceClass.getSimpleName(), maybeServiceVersion != null ? maybeServiceVersion : "0.0.0"));
String maybeRemotingVersion = OkHttpClients.class.getPackage().getImplementationVersion();
augmentedAgent = augmentedAgent.addAgent(UserAgent.Agent.of(UserAgents.CONJURE_AGENT_NAME, maybeRemotingVersion != null ? maybeRemotingVersion : "0.0.0"));
return augmentedAgent;
}
use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.
the class AtlasDbDialogueServiceProvider method create.
public static AtlasDbDialogueServiceProvider create(Refreshable<ServerListConfig> timeLockServerListConfig, DialogueClients.ReloadingFactory baseFactory, UserAgent userAgent, TaggedMetricRegistry taggedMetricRegistry) {
UserAgent versionedAgent = userAgent.addAgent(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
Refreshable<Map<String, RemoteServiceConfiguration>> timeLockRemoteConfigurations = timeLockServerListConfig.map(serverListConfig -> getServiceConfigurations(versionedAgent, serverListConfig));
DialogueClients.ReloadingFactory reloadingFactory = decorateForFailoverServices(baseFactory, timeLockRemoteConfigurations).withUserAgent(versionedAgent);
return new AtlasDbDialogueServiceProvider(reloadingFactory, taggedMetricRegistry, timeLockServerListConfig);
}
use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.
the class BroadcastDialogueClientFactory method create.
public static BroadcastDialogueClientFactory create(DialogueClients.ReloadingFactory baseFactory, Refreshable<ServerListConfig> serverListConfigSupplier, UserAgent userAgent, AuxiliaryRemotingParameters parameters) {
UserAgent versionedAgent = userAgent.addAgent(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
Refreshable<Map<String, RemoteServiceConfiguration>> timeLockRemoteConfigurations = serverListConfigSupplier.map(serverListConfig -> createRemoteServiceConfigurations(serverListConfig, versionedAgent, parameters));
DialogueClients.ReloadingFactory reloadingFactory = baseFactory.reloading(timeLockRemoteConfigurations.map(DialogueClientOptions::toServicesConfigBlock)).withUserAgent(versionedAgent);
return new BroadcastDialogueClientFactory(reloadingFactory, serverListConfigSupplier);
}
Aggregations