Task Status refactorings#556
Merged
Merged
Conversation
Since we're fully breaking backwards compatibility anyway, we can take the opportunity and clean up backwards compatibility related code.
Previously, the `Task` struct had lots of runtime related fields such as - `enqueue_at`: When a task should be enqueued. - `enqueued_at`: When a task has been enqueued. - `start`: When a task was started. - `end`: When a task finished. - `result`: The outcome of a task. The problem with these was that all of them only made sense when the task was in a specific state. E.g. `enqueue_at` was only necessary when a task was `Queued`, `start` only made sense when a task was at least started, etc. Whenever the state of a task changed, those invariants needed to be enforced, which was prone to error as it was really easy to just forget about something. The new design moves all of those fields and moves them into the `TaskStatus` enum as struct variants. This made the code slightly more complex, but significantly more robust.
e577bc7 to
57101a5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #556 +/- ##
==========================================
- Coverage 79.49% 79.23% -0.26%
==========================================
Files 75 75
Lines 5573 5653 +80
==========================================
+ Hits 4430 4479 +49
- Misses 1143 1174 +31 ☔ View full report in Codecov by Sentry. |
Test Results 3 files ±0 19 suites - 3 3m 4s ⏱️ ±0s Results for commit 1ce4e1f. ± Comparison against base commit 31878c4. This pull request removes 2 tests.♻️ This comment has been updated with latest results. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the
Taskstruct had lots of runtime related fields such asenqueue_at: When a task should be enqueued.enqueued_at: When a task has been enqueued.start: When a task was started.end: When a task finished.result: The outcome of a task.The problem with these was that all of them only made sense when the
task was in a specific state.
E.g.
enqueue_atwas only necessary when a task wasStashed,startonly made sense when a task was at least started, etc.Whenever the state of a task changed, those invariants needed to be
enforced, which was prone to error as it was really easy to just forget
about something.
The new design takes all of those fields and moves them into the
TaskStatusenum as struct variants.This made the code slightly more verbose, but significantly more robust.