Skip to content

Commit 67128e6

Browse files
algolia-botmillotp
andcommitted
fix(clients): use the dsn with the read transporter (generated)
algolia/api-clients-automation#3781 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 83f9e56 commit 67128e6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

algoliasearch/src/main/java/com/algolia/api/RecommendClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ private static List<Host> getDefaultHosts(String appId) {
3737
hosts.add(new Host(appId + ".algolia.net", EnumSet.of(CallType.WRITE)));
3838

3939
List<Host> commonHosts = new ArrayList<>();
40-
hosts.add(new Host(appId + "-1.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
41-
hosts.add(new Host(appId + "-2.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
42-
hosts.add(new Host(appId + "-3.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
40+
commonHosts.add(new Host(appId + "-1.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
41+
commonHosts.add(new Host(appId + "-2.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
42+
commonHosts.add(new Host(appId + "-3.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
4343

4444
Collections.shuffle(commonHosts, new Random());
4545

algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ private static List<Host> getDefaultHosts(String appId) {
4949
hosts.add(new Host(appId + ".algolia.net", EnumSet.of(CallType.WRITE)));
5050

5151
List<Host> commonHosts = new ArrayList<>();
52-
hosts.add(new Host(appId + "-1.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
53-
hosts.add(new Host(appId + "-2.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
54-
hosts.add(new Host(appId + "-3.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
52+
commonHosts.add(new Host(appId + "-1.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
53+
commonHosts.add(new Host(appId + "-2.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
54+
commonHosts.add(new Host(appId + "-3.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE)));
5555

5656
Collections.shuffle(commonHosts, new Random());
5757

algoliasearch/src/main/java/com/algolia/internal/HttpRequester.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.algolia.internal.interceptors.GzipRequestInterceptor;
77
import com.algolia.internal.interceptors.HeaderInterceptor;
88
import com.algolia.internal.interceptors.LogInterceptor;
9+
import com.algolia.utils.UseReadTransporter;
910
import com.fasterxml.jackson.core.type.TypeReference;
1011
import com.fasterxml.jackson.databind.JavaType;
1112
import java.io.IOException;
@@ -72,7 +73,12 @@ private <T> T execute(@Nonnull HttpRequest httpRequest, RequestOptions requestOp
7273
RequestBody requestBody = createRequestBody(httpRequest);
7374

7475
// Build the HTTP request.
75-
Request request = new Request.Builder().url(url).headers(headers).method(httpRequest.getMethod(), requestBody).build();
76+
Request.Builder requestBuilder = new Request.Builder().url(url).headers(headers).method(httpRequest.getMethod(), requestBody);
77+
if (httpRequest.isRead()) {
78+
requestBuilder.tag(new UseReadTransporter());
79+
}
80+
81+
Request request = requestBuilder.build();
7682

7783
// Get or adjust the HTTP client according to request options.
7884
OkHttpClient client = getOkHttpClient(requestOptions);

0 commit comments

Comments
 (0)