-
Notifications
You must be signed in to change notification settings - Fork 122
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
[Data sync] Rewrite data and photo sync workers to be more robust and readable #2867
Conversation
3a0d9d4
to
375a906
Compare
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 took a first pass and left some comments. Will take another pass soon.
ground/src/main/java/com/google/android/ground/persistence/sync/MediaUploadWorker.kt
Show resolved
Hide resolved
@@ -40,3 +42,5 @@ object Debug { | |||
null | |||
} | |||
} | |||
|
|||
fun Throwable.priority() = if (this is FirebaseNetworkException) Log.DEBUG else Log.ERROR |
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.
How about adding a check here and log to console?
Then we can continue to use Timber.e
normally in all classes
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.
Those events shouldn't be shown as errors in local logs either, and I'm not sure we want to have the priority change magically without any indication in the code doing the logging.
} catch (t: Throwable) { | ||
Timber.e(t, "Failed to upload photo") | ||
kotlin.Result.failure(t) | ||
Timber.log(t.priority(), t, "Photo upload failed") |
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.
Please see the other comment regarding reverting this change
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.
See response in other comment. Perhaps an extension function would be more elegant here? Timber.log
override with no "priority", for example?
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.
Forked this discussion into a suggestion in #2891.
ground/src/main/java/com/google/android/ground/repository/MutationRepository.kt
Outdated
Show resolved
Hide resolved
ground/src/main/java/com/google/android/ground/model/submission/UploadQueueEntry.kt
Outdated
Show resolved
Hide resolved
…o gino-m/2840/improve-upload-queue-1
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.
@shobhitagarwal1612 PTAL at my comments/questions
ground/src/main/java/com/google/android/ground/model/submission/UploadQueueEntry.kt
Outdated
Show resolved
Hide resolved
ground/src/main/java/com/google/android/ground/repository/MutationRepository.kt
Outdated
Show resolved
Hide resolved
@@ -40,3 +42,5 @@ object Debug { | |||
null | |||
} | |||
} | |||
|
|||
fun Throwable.priority() = if (this is FirebaseNetworkException) Log.DEBUG else Log.ERROR |
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.
Those events shouldn't be shown as errors in local logs either, and I'm not sure we want to have the priority change magically without any indication in the code doing the logging.
} catch (t: Throwable) { | ||
Timber.e(t, "Failed to upload photo") | ||
kotlin.Result.failure(t) | ||
Timber.log(t.priority(), t, "Photo upload failed") |
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.
See response in other comment. Perhaps an extension function would be more elegant here? Timber.log
override with no "priority", for example?
…om/google/ground-android into gino-m/2840/improve-upload-queue-1
UploadQueueEntry
wrapper / grouping for mutations to be used by the workers and UI.Towards #2840