-
Notifications
You must be signed in to change notification settings - Fork 137
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
Task Status refactorings #556
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. |
Previously, the
Task
struct 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_at
was only necessary when a task wasStashed
,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 takes all of those fields and moves them into the
TaskStatus
enum as struct variants.This made the code slightly more verbose, but significantly more robust.