Skip to content

Commit 3ef59d0

Browse files
committed
feat: add initialConfiguration to client Builder
1 parent f913167 commit 3ef59d0

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ java {
1111
}
1212

1313
group = 'cloud.eppo'
14-
version = '3.0.3-SNAPSHOT'
14+
version = '3.1.0-SNAPSHOT'
1515
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
1616

1717
import org.apache.tools.ant.filters.ReplaceTokens
@@ -31,7 +31,7 @@ repositories {
3131

3232
dependencies {
3333
// Re-export classes and interfaces that will be used upstream
34-
api 'cloud.eppo:sdk-common-jvm:3.1.1-SNAPSHOT'
34+
api 'cloud.eppo:sdk-common-jvm:3.2.0-SNAPSHOT'
3535

3636
implementation 'com.github.zafarkhaja:java-semver:0.10.2'
3737
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1'
@@ -40,7 +40,7 @@ dependencies {
4040
// Logback classic 1.3.x is compatible with java 8
4141
implementation 'ch.qos.logback:logback-classic:1.3.14'
4242

43-
testImplementation 'cloud.eppo:sdk-common-jvm:3.0.0-SNAPSHOT:tests'
43+
testImplementation 'cloud.eppo:sdk-common-jvm:3.2.0-SNAPSHOT:tests'
4444
testImplementation platform('org.junit:junit-bom:5.10.2')
4545
testImplementation 'org.junit.jupiter:junit-jupiter'
4646
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.2'

src/main/java/com/eppo/sdk/EppoClient.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.eppo.sdk;
22

33
import cloud.eppo.BaseEppoClient;
4+
import cloud.eppo.api.Configuration;
45
import cloud.eppo.logging.AssignmentLogger;
56
import cloud.eppo.logging.BanditLogger;
67
import com.eppo.sdk.helpers.AppDetails;
78
import com.eppo.sdk.helpers.FetchConfigurationsTask;
89
import java.util.Timer;
10+
import java.util.concurrent.CompletableFuture;
911
import org.slf4j.Logger;
1012
import org.slf4j.LoggerFactory;
1113

@@ -41,9 +43,20 @@ private EppoClient(
4143
String sdkVersion,
4244
AssignmentLogger assignmentLogger,
4345
BanditLogger banditLogger,
44-
boolean isGracefulModel) {
46+
boolean isGracefulModel,
47+
CompletableFuture<Configuration> initialConfiguration) {
4548
super(
46-
apiKey, host, sdkName, sdkVersion, assignmentLogger, banditLogger, isGracefulModel, false);
49+
apiKey,
50+
host,
51+
sdkName,
52+
sdkVersion,
53+
assignmentLogger,
54+
banditLogger,
55+
null,
56+
isGracefulModel,
57+
false,
58+
true,
59+
initialConfiguration);
4760
}
4861

4962
/** Stops the client from polling Eppo for updated flag and bandit configurations */
@@ -62,6 +75,7 @@ public static class Builder {
6275
private boolean forceReinitialize = DEFAULT_FORCE_REINITIALIZE;
6376
private long pollingIntervalMs = DEFAULT_POLLING_INTERVAL_MS;
6477
private String host = DEFAULT_HOST;
78+
private CompletableFuture<Configuration> initialConfiguration;
6579

6680
/** Sets the API Key--created within the eppo application--to use. This is required. */
6781
public Builder apiKey(String apiKey) {
@@ -125,6 +139,12 @@ public Builder host(String host) {
125139
return this;
126140
}
127141

142+
/** Sets the initial configuration for the client. */
143+
public Builder initialConfiguration(CompletableFuture<Configuration> initialConfiguration) {
144+
this.initialConfiguration = initialConfiguration;
145+
return this;
146+
}
147+
128148
public EppoClient buildAndInit() {
129149
AppDetails appDetails = AppDetails.getInstance();
130150
String sdkName = appDetails.getName();
@@ -143,7 +163,14 @@ public EppoClient buildAndInit() {
143163

144164
instance =
145165
new EppoClient(
146-
apiKey, sdkName, sdkVersion, host, assignmentLogger, banditLogger, isGracefulMode);
166+
apiKey,
167+
sdkName,
168+
sdkVersion,
169+
host,
170+
assignmentLogger,
171+
banditLogger,
172+
isGracefulMode,
173+
initialConfiguration);
147174

148175
// Stop any active polling
149176
stopPolling();

0 commit comments

Comments
 (0)