-
Notifications
You must be signed in to change notification settings - Fork 61
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
RUM-5977 create UploadSchedulerStrategy interface and default implementation #2222
RUM-5977 create UploadSchedulerStrategy interface and default implementation #2222
Conversation
1c08628
to
8663f6b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2222 +/- ##
===========================================
+ Coverage 69.97% 69.99% +0.02%
===========================================
Files 726 727 +1
Lines 27033 27042 +9
Branches 4555 4557 +2
===========================================
+ Hits 18915 18927 +12
+ Misses 6838 6836 -2
+ Partials 1280 1279 -1
|
throwable: Throwable? | ||
): Long { | ||
if (uploadAttempts > 0 && throwable == null && lastStatusCode == HTTP_ACCEPTED) { | ||
decreaseInterval() |
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.
Question, if the upload has succeeded after some failed attempts, why not just recover to the default delay immediately?
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.
So far I've kept the historical behaviour of our backoff strategy. We will have future tickets to make a different implementations
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!
f36165d
to
04b96ad
Compare
interface UploadSchedulerStrategy { | ||
|
||
/** | ||
* Should return the delay in millisecond to wait until the next upload attempt |
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.
* Should return the delay in millisecond to wait until the next upload attempt | |
* Should return the delay in milliseconds to wait until the next upload attempt |
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.
👍
/** | ||
* Should return the delay in millisecond to wait until the next upload attempt | ||
* is performed. | ||
* @param featureName the name of the feature for which a new upload will be scheduled |
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.
since we are exposing feature name here, maybe we should mention that they are listed in the Feature.Companion
object of the Feature
interface?
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.
Good idea
* Should return the delay in millisecond to wait until the next upload attempt | ||
* is performed. | ||
* @param featureName the name of the feature for which a new upload will be scheduled | ||
* @param uploadAttempts the number of requests that were attempted during this run. Will be zero if the device |
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.
Maybe we should elaborate what is the meaning of the run
here? Is it for a single batch or for all batches in general?
* is not ready (e.g.: when offline or with low battery). If multiple batches can be uploaded, the attempts will | ||
* stop at the first failure. | ||
* @param lastStatusCode the HTTP status code of the last request (if available). A successful upload will have a | ||
* status code 202 (Accepted). When null, it means that |
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.
Sentence ending is missing
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.
👍
* is not ready (e.g.: when offline or with low battery). If multiple batches can be uploaded, the attempts will | ||
* stop at the first failure. | ||
* @param lastStatusCode the HTTP status code of the last request (if available). A successful upload will have a | ||
* status code 202 (Accepted). When null, it means that |
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.
side note: One of the dangers of exposing this interface (if it is exposed to the user configuration, apart of messing up with time unit) is that implementations may wrongly check for 200 status code instead.
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.
This will be exposed, but we won't document it in the website, so almost no one will implement it. Also it is mentioned in the documentation that they should check for a 202.
lastBatchUploadStatus?.code, | ||
lastBatchUploadStatus?.throwable |
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.
What if we simply pass lastBatchUploadStatus
as a whole here? Does it have a downside?
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.
I'm not keen of making the whole UploadStatus
public. WDYT?
internal val uploadConfiguration: DataUploadConfiguration | ||
) : UploadSchedulerStrategy { | ||
|
||
private val currentDelays = mutableMapOf<String, Long>() |
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.
We probably need to make this one thread-safe, just in case. Even though we have only a single upload thread currently, it may change in the future.
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.
Good point
|
||
// endregion | ||
|
||
// region Internal |
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.
missing // endregion
for this one
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.
👍
04b96ad
to
e232d84
Compare
e232d84
to
ad6e8f1
Compare
What does this PR do?
Creates a basic interface to let customers decide how long to wait after an upload before trying again, based on the number of upload attempts, status code and exceptions.