Skip to content
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

Merged
merged 2 commits into from
Aug 31, 2023

Conversation

cre8ivejp
Copy link
Member

@cre8ivejp cre8ivejp commented Aug 30, 2023

Thins done

  • Fixed the evaluation scheduler not being reset when the request succeeds when the first attempt failed
  • Refactor the reschedule function to keep the consistency with the Android SDK

@@ -1,7 +1,7 @@
import Foundation

final class EvaluationForegroundTask: ScheduledTask {
private weak var component: Component?
private let component: Component
Copy link
Member Author

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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// reset the scheduler to use the default polling interval configured in the BKTConfig
if (retryCount > 0) {
self?.retryCount = 0
self?.reschedule(interval: pollingInterval)
Copy link
Member Author

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,
Copy link
Member Author

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.

@duyhungtnn
Copy link
Collaborator

@cre8ivejp this PR looks good for me.

featureId: FEATURE_ID_INT,
featureVersion: 3,
featureVersion: 4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor

@masaaania masaaania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@cre8ivejp cre8ivejp merged commit 8df5ae3 into main Aug 31, 2023
@cre8ivejp cre8ivejp deleted the evaluation-polling branch August 31, 2023 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants