|
| 1 | +/** |
| 2 | + * Copyright 2024-2025 Wingify Software Pvt. Ltd. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.vwo.models.user; |
| 17 | + |
| 18 | +import com.vwo.constants.Constants; |
| 19 | + |
| 20 | +/** |
| 21 | + * Retry configuration class. |
| 22 | + * Used to configure network retry behavior with exponential backoff. |
| 23 | + */ |
| 24 | +public class RetryConfig { |
| 25 | + private Boolean shouldRetry; |
| 26 | + private Integer maxRetries; |
| 27 | + private Integer initialDelay; |
| 28 | + private Integer backoffMultiplier; |
| 29 | + |
| 30 | + public RetryConfig() { |
| 31 | + this.shouldRetry = Constants.DEFAULT_SHOULD_RETRY; |
| 32 | + this.maxRetries = Constants.DEFAULT_MAX_RETRIES; |
| 33 | + this.initialDelay = Constants.DEFAULT_INITIAL_DELAY; |
| 34 | + this.backoffMultiplier = Constants.DEFAULT_BACKOFF_MULTIPLIER; |
| 35 | + } |
| 36 | + |
| 37 | + public RetryConfig(Boolean shouldRetry, Integer maxRetries, Integer initialDelay, Integer backoffMultiplier) { |
| 38 | + this.shouldRetry = shouldRetry; |
| 39 | + this.maxRetries = maxRetries; |
| 40 | + this.initialDelay = initialDelay; |
| 41 | + this.backoffMultiplier = backoffMultiplier; |
| 42 | + } |
| 43 | + |
| 44 | + // Copy constructor |
| 45 | + public RetryConfig(RetryConfig other) { |
| 46 | + this.shouldRetry = other.shouldRetry; |
| 47 | + this.maxRetries = other.maxRetries; |
| 48 | + this.initialDelay = other.initialDelay; |
| 49 | + this.backoffMultiplier = other.backoffMultiplier; |
| 50 | + } |
| 51 | + |
| 52 | + public Boolean getShouldRetry() { |
| 53 | + return shouldRetry; |
| 54 | + } |
| 55 | + |
| 56 | + public void setShouldRetry(Boolean shouldRetry) { |
| 57 | + this.shouldRetry = shouldRetry; |
| 58 | + } |
| 59 | + |
| 60 | + public Integer getMaxRetries() { |
| 61 | + return maxRetries; |
| 62 | + } |
| 63 | + |
| 64 | + public void setMaxRetries(Integer maxRetries) { |
| 65 | + this.maxRetries = maxRetries; |
| 66 | + } |
| 67 | + |
| 68 | + public Integer getInitialDelay() { |
| 69 | + return initialDelay; |
| 70 | + } |
| 71 | + |
| 72 | + public void setInitialDelay(Integer initialDelay) { |
| 73 | + this.initialDelay = initialDelay; |
| 74 | + } |
| 75 | + |
| 76 | + public Integer getBackoffMultiplier() { |
| 77 | + return backoffMultiplier; |
| 78 | + } |
| 79 | + |
| 80 | + public void setBackoffMultiplier(Integer backoffMultiplier) { |
| 81 | + this.backoffMultiplier = backoffMultiplier; |
| 82 | + } |
| 83 | + @Override |
| 84 | + public String toString() { |
| 85 | + return "RetryConfig{" + |
| 86 | + "shouldRetry=" + shouldRetry + |
| 87 | + ", maxRetries=" + maxRetries + |
| 88 | + ", initialDelay=" + initialDelay + |
| 89 | + ", backoffMultiplier=" + backoffMultiplier + |
| 90 | + '}'; |
| 91 | + } |
| 92 | +} |
0 commit comments