-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: evaluation scheduler not being reset when the request succeeds #37
Conversation
@@ -1,7 +1,7 @@ | |||
import Foundation | |||
|
|||
final class EvaluationForegroundTask: ScheduledTask { | |||
private weak var component: Component? | |||
private let component: Component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component at this point can't be nil.
@@ -20,11 +20,10 @@ final class EvaluationForegroundTask: ScheduledTask { | |||
self.maxRetryCount = maxRetryCount | |||
} | |||
|
|||
private func reschedule(isRetrying: Bool) { | |||
private func reschedule(interval: Int64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored this function to keep the consistency with Android SDK.
Reference: https://github.com/bucketeer-io/android-client-sdk/blob/main/bucketeer/src/main/kotlin/io/bucketeer/sdk/android/internal/scheduler/EvaluationForegroundTask.kt#L23-L31
// reset the scheduler to use the default polling interval configured in the BKTConfig | ||
if (retryCount > 0) { | ||
self?.retryCount = 0 | ||
self?.reschedule(interval: pollingInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes the polling interval setting not being reset when the request succeeds after retrying.
@@ -93,7 +93,7 @@ final class EvaluationForegroundTaskTests: XCTestCase { | |||
let task = EvaluationForegroundTask( | |||
component: component, | |||
queue: dispatchQueue, | |||
retryPollingInterval: 1, | |||
retryPollingInterval: 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 millisecond is too low and the test could fail sometimes, so I'm increasing it by 1 second.
@cre8ivejp this PR looks good for me. |
featureId: FEATURE_ID_INT, | ||
featureVersion: 3, | ||
featureVersion: 4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!
Thins done