@@ -13,7 +13,8 @@ public class PermitConfig {
1313 private final String apiUrl ;
1414 private final Boolean debugMode ;
1515 private final Boolean proxyFactsViaPdp ;
16- private final int factsSyncTimeout ;
16+ private final Integer factsSyncTimeout ;
17+ private final FactsSyncTimeoutPolicy factsSyncTimeoutPolicy ;
1718
1819 // logger config
1920 private final String logLevel ;
@@ -49,6 +50,7 @@ private PermitConfig(Builder builder) {
4950 this .context = builder .context ;
5051 this .proxyFactsViaPdp = builder .proxyFactsViaPdp ;
5152 this .factsSyncTimeout = builder .factsSyncTimeout ;
53+ this .factsSyncTimeoutPolicy = builder .factsSyncTimeoutPolicy ;
5254 String runtimeVersion = Permit .class .getPackage ().getImplementationVersion ();
5355 this .version = (runtimeVersion == null ) ? defaultVersion : runtimeVersion ;
5456 }
@@ -113,10 +115,23 @@ public Boolean isProxyFactsViaPdp() {
113115 *
114116 * @return The facts synchronization timeout.
115117 */
116- public int getFactsSyncTimeout () {
118+ public Integer getFactsSyncTimeout () {
117119 return factsSyncTimeout ;
118120 }
119121
122+ /**
123+ * Returns the timeout policy for facts synchronization.
124+ * When proxy_facts_via_pdp is enabled, this determines what happens when the facts synchronization timeout is reached.
125+ * Values can be:
126+ * * IGNORE - Respond immediately when data update did not apply within the timeout period
127+ * * FAIL - Respond with 424 status code when data update did not apply within the timeout period
128+ *
129+ * @return The facts synchronization timeout policy, or null if not set.
130+ */
131+ public FactsSyncTimeoutPolicy getFactsSyncTimeoutPolicy () {
132+ return factsSyncTimeoutPolicy ;
133+ }
134+
120135 /**
121136 * Returns the log level configured for the Permit SDK Logger.
122137 *
@@ -231,7 +246,8 @@ public static class Builder {
231246 private String apiUrl = "https://api.permit.io" ;
232247 private Boolean debugMode = false ;
233248 private Boolean proxyFactsViaPdp = false ;
234- private int factsSyncTimeout = 0 ;
249+ private Integer factsSyncTimeout = null ;
250+ private FactsSyncTimeoutPolicy factsSyncTimeoutPolicy = null ;
235251
236252 // logger config
237253 private String logLevel = "info" ;
@@ -320,11 +336,45 @@ public Builder withProxyFactsViaPdp(Boolean proxyFactsViaPdp) {
320336 * @param factsSyncTimeout The facts synchronization timeout to be set.
321337 * @return The updated {@code Builder} object.
322338 */
323- public Builder withFactsSyncTimeout (int factsSyncTimeout ) {
339+ public Builder withFactsSyncTimeout (Integer factsSyncTimeout ) {
324340 this .factsSyncTimeout = factsSyncTimeout ;
325341 return this ;
326342 }
327343
344+ /**
345+ * Sets the timeout policy for facts synchronization.
346+ * This determines what happens when the facts synchronization timeout is reached.
347+ *
348+ * @param factsSyncTimeoutPolicy The facts synchronization timeout policy to be set.
349+ * Must be "ignore" or "fail".
350+ * @return This Builder instance.
351+ * @throws IllegalArgumentException If the policy value is not "ignore" or "fail".
352+ */
353+ public Builder withFactsSyncTimeoutPolicy (String factsSyncTimeoutPolicy ) {
354+ if (factsSyncTimeoutPolicy == null ) {
355+ this .factsSyncTimeoutPolicy = null ;
356+ } else {
357+ try {
358+ this .factsSyncTimeoutPolicy = FactsSyncTimeoutPolicy .fromString (factsSyncTimeoutPolicy );
359+ } catch (IllegalArgumentException e ) {
360+ throw new IllegalArgumentException ("factsSyncTimeoutPolicy must be either 'ignore' or 'fail'" , e );
361+ }
362+ }
363+ return this ;
364+ }
365+
366+ /**
367+ * Sets the timeout policy for facts synchronization.
368+ * This determines what happens when the facts synchronization timeout is reached.
369+ *
370+ * @param policy The facts synchronization timeout policy to be set.
371+ * @return This Builder instance.
372+ */
373+ public Builder withFactsSyncTimeoutPolicy (FactsSyncTimeoutPolicy policy ) {
374+ this .factsSyncTimeoutPolicy = policy ;
375+ return this ;
376+ }
377+
328378 /**
329379 * Sets the log level configured for the Permit SDK Logger.
330380 *
0 commit comments