1
1
package com .eppo .sdk ;
2
2
3
3
import cloud .eppo .BaseEppoClient ;
4
+ import cloud .eppo .api .Configuration ;
4
5
import cloud .eppo .logging .AssignmentLogger ;
5
6
import cloud .eppo .logging .BanditLogger ;
6
7
import com .eppo .sdk .helpers .AppDetails ;
7
8
import com .eppo .sdk .helpers .FetchConfigurationsTask ;
8
9
import java .util .Timer ;
10
+ import java .util .concurrent .CompletableFuture ;
9
11
import org .slf4j .Logger ;
10
12
import org .slf4j .LoggerFactory ;
11
13
@@ -41,9 +43,20 @@ private EppoClient(
41
43
String sdkVersion ,
42
44
AssignmentLogger assignmentLogger ,
43
45
BanditLogger banditLogger ,
44
- boolean isGracefulModel ) {
46
+ boolean isGracefulModel ,
47
+ CompletableFuture <Configuration > initialConfiguration ) {
45
48
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 );
47
60
}
48
61
49
62
/** Stops the client from polling Eppo for updated flag and bandit configurations */
@@ -62,6 +75,7 @@ public static class Builder {
62
75
private boolean forceReinitialize = DEFAULT_FORCE_REINITIALIZE ;
63
76
private long pollingIntervalMs = DEFAULT_POLLING_INTERVAL_MS ;
64
77
private String host = DEFAULT_HOST ;
78
+ private CompletableFuture <Configuration > initialConfiguration ;
65
79
66
80
/** Sets the API Key--created within the eppo application--to use. This is required. */
67
81
public Builder apiKey (String apiKey ) {
@@ -125,6 +139,12 @@ public Builder host(String host) {
125
139
return this ;
126
140
}
127
141
142
+ /** Sets the initial configuration for the client. */
143
+ public Builder initialConfiguration (CompletableFuture <Configuration > initialConfiguration ) {
144
+ this .initialConfiguration = initialConfiguration ;
145
+ return this ;
146
+ }
147
+
128
148
public EppoClient buildAndInit () {
129
149
AppDetails appDetails = AppDetails .getInstance ();
130
150
String sdkName = appDetails .getName ();
@@ -143,7 +163,14 @@ public EppoClient buildAndInit() {
143
163
144
164
instance =
145
165
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 );
147
174
148
175
// Stop any active polling
149
176
stopPolling ();
0 commit comments