From f913167aeb28913a59cefaf28a7740777c6420a2 Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Wed, 18 Sep 2024 14:22:59 -0600 Subject: [PATCH 1/3] adjust test as BaseEppoClient no longer accesses the configuration through the requester --- build.gradle | 4 ++-- src/test/java/com/eppo/sdk/EppoClientTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 0b6adde..d07496b 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ java { } group = 'cloud.eppo' -version = '3.0.2-SNAPSHOT' +version = '3.0.3-SNAPSHOT' ext.isReleaseVersion = !version.endsWith("SNAPSHOT") import org.apache.tools.ant.filters.ReplaceTokens @@ -31,7 +31,7 @@ repositories { dependencies { // Re-export classes and interfaces that will be used upstream - api 'cloud.eppo:sdk-common-jvm:3.0.2' + api 'cloud.eppo:sdk-common-jvm:3.1.1-SNAPSHOT' implementation 'com.github.zafarkhaja:java-semver:0.10.2' implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1' diff --git a/src/test/java/com/eppo/sdk/EppoClientTest.java b/src/test/java/com/eppo/sdk/EppoClientTest.java index d71a14f..193df02 100644 --- a/src/test/java/com/eppo/sdk/EppoClientTest.java +++ b/src/test/java/com/eppo/sdk/EppoClientTest.java @@ -276,7 +276,7 @@ private void uninitClient() { private void initBuggyClient() { try { EppoClient eppoClient = initClient(DUMMY_FLAG_API_KEY); - Field configurationStoreField = BaseEppoClient.class.getDeclaredField("requestor"); + Field configurationStoreField = BaseEppoClient.class.getDeclaredField("configurationStore"); configurationStoreField.setAccessible(true); configurationStoreField.set(eppoClient, null); } catch (NoSuchFieldException | IllegalAccessException e) { From 3ef59d08b38f4a14e013cd97ee83f8fe5c676560 Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Wed, 25 Sep 2024 09:19:40 -0600 Subject: [PATCH 2/3] feat: add initialConfiguration to client Builder --- build.gradle | 6 ++-- src/main/java/com/eppo/sdk/EppoClient.java | 33 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index d07496b..a452946 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ java { } group = 'cloud.eppo' -version = '3.0.3-SNAPSHOT' +version = '3.1.0-SNAPSHOT' ext.isReleaseVersion = !version.endsWith("SNAPSHOT") import org.apache.tools.ant.filters.ReplaceTokens @@ -31,7 +31,7 @@ repositories { dependencies { // Re-export classes and interfaces that will be used upstream - api 'cloud.eppo:sdk-common-jvm:3.1.1-SNAPSHOT' + api 'cloud.eppo:sdk-common-jvm:3.2.0-SNAPSHOT' implementation 'com.github.zafarkhaja:java-semver:0.10.2' implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1' @@ -40,7 +40,7 @@ dependencies { // Logback classic 1.3.x is compatible with java 8 implementation 'ch.qos.logback:logback-classic:1.3.14' - testImplementation 'cloud.eppo:sdk-common-jvm:3.0.0-SNAPSHOT:tests' + testImplementation 'cloud.eppo:sdk-common-jvm:3.2.0-SNAPSHOT:tests' testImplementation platform('org.junit:junit-bom:5.10.2') testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.2' diff --git a/src/main/java/com/eppo/sdk/EppoClient.java b/src/main/java/com/eppo/sdk/EppoClient.java index d3509a2..a6805d1 100644 --- a/src/main/java/com/eppo/sdk/EppoClient.java +++ b/src/main/java/com/eppo/sdk/EppoClient.java @@ -1,11 +1,13 @@ package com.eppo.sdk; import cloud.eppo.BaseEppoClient; +import cloud.eppo.api.Configuration; import cloud.eppo.logging.AssignmentLogger; import cloud.eppo.logging.BanditLogger; import com.eppo.sdk.helpers.AppDetails; import com.eppo.sdk.helpers.FetchConfigurationsTask; import java.util.Timer; +import java.util.concurrent.CompletableFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,9 +43,20 @@ private EppoClient( String sdkVersion, AssignmentLogger assignmentLogger, BanditLogger banditLogger, - boolean isGracefulModel) { + boolean isGracefulModel, + CompletableFuture initialConfiguration) { super( - apiKey, host, sdkName, sdkVersion, assignmentLogger, banditLogger, isGracefulModel, false); + apiKey, + host, + sdkName, + sdkVersion, + assignmentLogger, + banditLogger, + null, + isGracefulModel, + false, + true, + initialConfiguration); } /** Stops the client from polling Eppo for updated flag and bandit configurations */ @@ -62,6 +75,7 @@ public static class Builder { private boolean forceReinitialize = DEFAULT_FORCE_REINITIALIZE; private long pollingIntervalMs = DEFAULT_POLLING_INTERVAL_MS; private String host = DEFAULT_HOST; + private CompletableFuture initialConfiguration; /** Sets the API Key--created within the eppo application--to use. This is required. */ public Builder apiKey(String apiKey) { @@ -125,6 +139,12 @@ public Builder host(String host) { return this; } + /** Sets the initial configuration for the client. */ + public Builder initialConfiguration(CompletableFuture initialConfiguration) { + this.initialConfiguration = initialConfiguration; + return this; + } + public EppoClient buildAndInit() { AppDetails appDetails = AppDetails.getInstance(); String sdkName = appDetails.getName(); @@ -143,7 +163,14 @@ public EppoClient buildAndInit() { instance = new EppoClient( - apiKey, sdkName, sdkVersion, host, assignmentLogger, banditLogger, isGracefulMode); + apiKey, + sdkName, + sdkVersion, + host, + assignmentLogger, + banditLogger, + isGracefulMode, + initialConfiguration); // Stop any active polling stopPolling(); From 5c2912469eb279dd34f8650d841bcce3690f3f4e Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Mon, 30 Sep 2024 09:04:22 -0600 Subject: [PATCH 3/3] drop initial config --- src/main/java/com/eppo/sdk/EppoClient.java | 23 +++------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/eppo/sdk/EppoClient.java b/src/main/java/com/eppo/sdk/EppoClient.java index a6805d1..88aad6c 100644 --- a/src/main/java/com/eppo/sdk/EppoClient.java +++ b/src/main/java/com/eppo/sdk/EppoClient.java @@ -1,13 +1,11 @@ package com.eppo.sdk; import cloud.eppo.BaseEppoClient; -import cloud.eppo.api.Configuration; import cloud.eppo.logging.AssignmentLogger; import cloud.eppo.logging.BanditLogger; import com.eppo.sdk.helpers.AppDetails; import com.eppo.sdk.helpers.FetchConfigurationsTask; import java.util.Timer; -import java.util.concurrent.CompletableFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,8 +41,7 @@ private EppoClient( String sdkVersion, AssignmentLogger assignmentLogger, BanditLogger banditLogger, - boolean isGracefulModel, - CompletableFuture initialConfiguration) { + boolean isGracefulModel) { super( apiKey, host, @@ -56,7 +53,7 @@ private EppoClient( isGracefulModel, false, true, - initialConfiguration); + null); } /** Stops the client from polling Eppo for updated flag and bandit configurations */ @@ -75,7 +72,6 @@ public static class Builder { private boolean forceReinitialize = DEFAULT_FORCE_REINITIALIZE; private long pollingIntervalMs = DEFAULT_POLLING_INTERVAL_MS; private String host = DEFAULT_HOST; - private CompletableFuture initialConfiguration; /** Sets the API Key--created within the eppo application--to use. This is required. */ public Builder apiKey(String apiKey) { @@ -139,12 +135,6 @@ public Builder host(String host) { return this; } - /** Sets the initial configuration for the client. */ - public Builder initialConfiguration(CompletableFuture initialConfiguration) { - this.initialConfiguration = initialConfiguration; - return this; - } - public EppoClient buildAndInit() { AppDetails appDetails = AppDetails.getInstance(); String sdkName = appDetails.getName(); @@ -163,14 +153,7 @@ public EppoClient buildAndInit() { instance = new EppoClient( - apiKey, - sdkName, - sdkVersion, - host, - assignmentLogger, - banditLogger, - isGracefulMode, - initialConfiguration); + apiKey, sdkName, sdkVersion, host, assignmentLogger, banditLogger, isGracefulMode); // Stop any active polling stopPolling();