@@ -71,11 +71,12 @@ public class OpenFeatureLocalResolveProvider implements FeatureProvider {
7171 private final StickyResolveStrategy stickyResolveStrategy ;
7272
7373 /**
74- * Creates a new OpenFeature provider for local flag resolution with default fallback strategy.
74+ * Creates a new OpenFeature provider for local flag resolution with default fallback strategy and
75+ * no retry.
7576 *
7677 * <p>This constructor uses {@link RemoteResolverFallback} as the default sticky resolve strategy,
7778 * which provides fallback to the remote Confidence service when the WASM resolver encounters
78- * missing materializations.
79+ * missing materializations. By default, no retry strategy is applied.
7980 *
8081 * <p>The provider will automatically determine the resolution mode (WASM or Java) based on the
8182 * {@code LOCAL_RESOLVE_MODE} environment variable, defaulting to WASM mode.
@@ -89,15 +90,14 @@ public class OpenFeatureLocalResolveProvider implements FeatureProvider {
8990 * @since 0.2.4
9091 */
9192 public OpenFeatureLocalResolveProvider (ApiSecret apiSecret , String clientSecret ) {
92- this (apiSecret , clientSecret , new RemoteResolverFallback ());
93+ this (apiSecret , clientSecret , new RemoteResolverFallback (), new NoRetryStrategy () );
9394 }
9495
9596 /**
96- * Creates a new OpenFeature provider for local flag resolution with configurable exposure
97- * logging .
97+ * Creates a new OpenFeature provider for local flag resolution with configurable sticky resolve
98+ * strategy and no retry .
9899 *
99- * <p>This is the primary constructor that allows full control over the provider configuration.
100- * The provider will automatically determine the resolution mode (WASM or Java) based on the
100+ * <p>The provider will automatically determine the resolution mode (WASM or Java) based on the
101101 * {@code LOCAL_RESOLVE_MODE} environment variable, defaulting to WASM mode.
102102 *
103103 * @param apiSecret the API credentials containing client ID and client secret for authenticating
@@ -111,16 +111,45 @@ public OpenFeatureLocalResolveProvider(ApiSecret apiSecret, String clientSecret)
111111 */
112112 public OpenFeatureLocalResolveProvider (
113113 ApiSecret apiSecret , String clientSecret , StickyResolveStrategy stickyResolveStrategy ) {
114+ this (apiSecret , clientSecret , stickyResolveStrategy , new NoRetryStrategy ());
115+ }
116+
117+ /**
118+ * Creates a new OpenFeature provider for local flag resolution with full configuration control.
119+ *
120+ * <p>This is the primary constructor that allows full control over the provider configuration,
121+ * including retry strategy. The provider will automatically determine the resolution mode (WASM
122+ * or Java) based on the {@code LOCAL_RESOLVE_MODE} environment variable, defaulting to WASM mode.
123+ *
124+ * @param apiSecret the API credentials containing client ID and client secret for authenticating
125+ * with the Confidence service. Create using {@code new ApiSecret("client-id",
126+ * "client-secret")}
127+ * @param clientSecret the client secret for your application, used for flag resolution
128+ * authentication. This is different from the API secret and is specific to your application
129+ * configuration
130+ * @param stickyResolveStrategy the strategy to use for handling sticky flag resolution
131+ * @param retryStrategy the retry strategy for WASM operations (use {@link NoRetryStrategy} to
132+ * disable retries or {@link ExponentialRetryStrategy} for exponential backoff)
133+ * @since 0.2.4
134+ */
135+ public OpenFeatureLocalResolveProvider (
136+ ApiSecret apiSecret ,
137+ String clientSecret ,
138+ StickyResolveStrategy stickyResolveStrategy ,
139+ RetryStrategy retryStrategy ) {
114140 final var env = System .getenv ("LOCAL_RESOLVE_MODE" );
115141 if (env != null && env .equals ("WASM" )) {
116142 this .flagResolverService =
117- LocalResolverServiceFactory .from (apiSecret , clientSecret , true , stickyResolveStrategy );
143+ LocalResolverServiceFactory .from (
144+ apiSecret , clientSecret , true , stickyResolveStrategy , retryStrategy );
118145 } else if (env != null && env .equals ("JAVA" )) {
119146 this .flagResolverService =
120- LocalResolverServiceFactory .from (apiSecret , clientSecret , false , stickyResolveStrategy );
147+ LocalResolverServiceFactory .from (
148+ apiSecret , clientSecret , false , stickyResolveStrategy , retryStrategy );
121149 } else {
122150 this .flagResolverService =
123- LocalResolverServiceFactory .from (apiSecret , clientSecret , true , stickyResolveStrategy );
151+ LocalResolverServiceFactory .from (
152+ apiSecret , clientSecret , true , stickyResolveStrategy , retryStrategy );
124153 }
125154 this .stickyResolveStrategy = stickyResolveStrategy ;
126155 this .clientSecret = clientSecret ;
@@ -141,10 +170,37 @@ public OpenFeatureLocalResolveProvider(
141170 String accountId ,
142171 String clientSecret ,
143172 StickyResolveStrategy stickyResolveStrategy ) {
173+ this (
174+ accountStateProvider ,
175+ accountId ,
176+ clientSecret ,
177+ stickyResolveStrategy ,
178+ new NoRetryStrategy ());
179+ }
180+
181+ /**
182+ * To be used for testing purposes only! This constructor allows to inject flags state for testing
183+ * the WASM resolver with full control over retry strategy.
184+ *
185+ * @param accountStateProvider a functional interface that provides AccountState instances
186+ * @param accountId the account ID
187+ * @param clientSecret the flag client key used to filter the flags
188+ * @param stickyResolveStrategy the strategy to use for handling sticky flag resolution
189+ * @param retryStrategy the retry strategy for WASM operations
190+ * @since 0.2.4
191+ */
192+ @ VisibleForTesting
193+ public OpenFeatureLocalResolveProvider (
194+ AccountStateProvider accountStateProvider ,
195+ String accountId ,
196+ String clientSecret ,
197+ StickyResolveStrategy stickyResolveStrategy ,
198+ RetryStrategy retryStrategy ) {
144199 this .stickyResolveStrategy = stickyResolveStrategy ;
145200 this .clientSecret = clientSecret ;
146201 this .flagResolverService =
147- LocalResolverServiceFactory .from (accountStateProvider , accountId , stickyResolveStrategy );
202+ LocalResolverServiceFactory .from (
203+ accountStateProvider , accountId , stickyResolveStrategy , retryStrategy );
148204 }
149205
150206 @ Override
0 commit comments