Skip to content

Commit e1a5b57

Browse files
authored
chore: use established constants for URL and endpoints (#67)
* Use a base URL consistent with other SDKs * don't version for release - major bugfix following
1 parent c83e925 commit e1a5b57

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = 'cloud.eppo'
9-
version = '3.5.1-SNAPSHOT'
9+
version = '3.5.2-SNAPSHOT'
1010
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
1111

1212
java {

src/main/java/cloud/eppo/BaseEppoClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class BaseEppoClient {
2727
new ObjectMapper()
2828
.registerModule(EppoModule.eppoModule()); // TODO: is this the best place for this?
2929

30-
protected static final String DEFAULT_HOST = "https://fscdn.eppo.cloud";
3130
protected final ConfigurationRequestor requestor;
3231

3332
private final IConfigurationStore configurationStore;
@@ -76,7 +75,7 @@ protected BaseEppoClient(
7675
"Unable to initialize Eppo SDK due to missing SDK name or version");
7776
}
7877
if (host == null) {
79-
host = DEFAULT_HOST;
78+
host = Constants.DEFAULT_BASE_URL;
8079
}
8180

8281
this.assignmentCache = assignmentCache;

src/main/java/cloud/eppo/ConfigurationRequestor.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
public class ConfigurationRequestor {
1111
private static final Logger log = LoggerFactory.getLogger(ConfigurationRequestor.class);
12-
private static final String FLAG_CONFIG_PATH = "/api/flag-config/v1/config";
13-
private static final String BANDIT_PARAMETER_PATH = "/api/flag-config/v1/bandits";
1412

1513
private final EppoHttpClient client;
1614
private final IConfigurationStore configurationStore;
@@ -90,13 +88,13 @@ void fetchAndSaveFromRemote() {
9088
// Reuse the `lastConfig` as its bandits may be useful
9189
Configuration lastConfig = configurationStore.getConfiguration();
9290

93-
byte[] flagConfigurationJsonBytes = client.get(FLAG_CONFIG_PATH);
91+
byte[] flagConfigurationJsonBytes = client.get(Constants.FLAG_CONFIG_ENDPOINT);
9492
Configuration.Builder configBuilder =
9593
Configuration.builder(flagConfigurationJsonBytes, expectObfuscatedConfig)
9694
.banditParametersFromConfig(lastConfig);
9795

9896
if (supportBandits && configBuilder.requiresUpdatedBanditModels()) {
99-
byte[] banditParametersJsonBytes = client.get(BANDIT_PARAMETER_PATH);
97+
byte[] banditParametersJsonBytes = client.get(Constants.BANDIT_ENDPOINT);
10098
configBuilder.banditParameters(banditParametersJsonBytes);
10199
}
102100

@@ -116,7 +114,7 @@ CompletableFuture<Void> fetchAndSaveFromRemoteAsync() {
116114

117115
remoteFetchFuture =
118116
client
119-
.getAsync(FLAG_CONFIG_PATH)
117+
.getAsync(Constants.FLAG_CONFIG_ENDPOINT)
120118
.thenApply(
121119
flagConfigJsonBytes -> {
122120
synchronized (this) {
@@ -128,7 +126,8 @@ CompletableFuture<Void> fetchAndSaveFromRemoteAsync() {
128126
if (supportBandits && configBuilder.requiresUpdatedBanditModels()) {
129127
byte[] banditParametersJsonBytes;
130128
try {
131-
banditParametersJsonBytes = client.getAsync(BANDIT_PARAMETER_PATH).get();
129+
banditParametersJsonBytes =
130+
client.getAsync(Constants.BANDIT_ENDPOINT).get();
132131
} catch (InterruptedException | ExecutionException e) {
133132
log.error("Error fetching from remote: " + e.getMessage());
134133
throw new RuntimeException(e);

src/main/java/cloud/eppo/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Constants {
2121
public static final String RAC_ENDPOINT = "/randomized_assignment/v3/config";
2222

2323
public static final String BANDIT_ENDPOINT = "/flag-config/v1/bandits";
24+
public static final String FLAG_CONFIG_ENDPOINT = "/flag-config/v1/config";
2425

2526
/** Caching Settings */
2627
public static final String EXPERIMENT_CONFIGURATION_CACHE_KEY = "experiment-configuration";

src/test/java/cloud/eppo/ConfigurationRequestorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testInitialConfigurationDoesntClobberFetch() throws IOException {
5858
String fetchedFlagConfig =
5959
FileUtils.readFileToString(differentFlagConfigFile, StandardCharsets.UTF_8);
6060

61-
when(mockHttpClient.getAsync("/api/flag-config/v1/config")).thenReturn(configFetchFuture);
61+
when(mockHttpClient.getAsync("/flag-config/v1/config")).thenReturn(configFetchFuture);
6262

6363
// Set initial config and verify that no config has been set yet.
6464
requestor.setInitialConfiguration(initialConfigFuture);
@@ -98,7 +98,7 @@ public void testBrokenFetchDoesntClobberCache() throws IOException {
9898
String flagConfig = FileUtils.readFileToString(initialFlagConfigFile, StandardCharsets.UTF_8);
9999
CompletableFuture<byte[]> configFetchFuture = new CompletableFuture<>();
100100

101-
when(mockHttpClient.getAsync("/api/flag-config/v1/config")).thenReturn(configFetchFuture);
101+
when(mockHttpClient.getAsync("/flag-config/v1/config")).thenReturn(configFetchFuture);
102102

103103
// Set initial config and verify that no config has been set yet.
104104
requestor.setInitialConfiguration(initialConfigFuture);
@@ -135,7 +135,7 @@ public void testCacheWritesAfterBrokenFetch() throws IOException {
135135
String flagConfig = FileUtils.readFileToString(initialFlagConfigFile, StandardCharsets.UTF_8);
136136
CompletableFuture<byte[]> configFetchFuture = new CompletableFuture<>();
137137

138-
when(mockHttpClient.getAsync("/api/flag-config/v1/config")).thenReturn(configFetchFuture);
138+
when(mockHttpClient.getAsync("/flag-config/v1/config")).thenReturn(configFetchFuture);
139139

140140
// Set initial config and verify that no config has been set yet.
141141
requestor.setInitialConfiguration(initialConfigFuture);

0 commit comments

Comments
 (0)