Skip to content

Conversation

@plutopulp
Copy link
Owner

Summary

Lays the groundwork for selective download cancellation. Adds domain types, observability, and event enrichment without behavioural changes.

Changes

Domain

  • Add CancelResult enum: explicit return type for upcoming cancel() method (CANCELLED, NOT_FOUND, ALREADY_TERMINAL)
  • Add CancelledFrom enum: distinguishes cancellation of queued vs in-progress downloads

Observability

  • Add cancelled field to DownloadStats for tracking cancelled download count

Events

  • Enrich DownloadCancelledEvent with required cancelled_from field
  • Worker emits cancelled_from=IN_PROGRESS on task cancellation

Context

This prepares the selective download cancellation feature. Next PR will add the actual manager.cancel(download_id) method using these foundations.

Introduces two new enums in rheo.domain.cancellation:
- CancelResult: explicit return type for cancel operations
- CancelledFrom: indicates download state when cancelled

These provide clear semantics for the upcoming cancel() implementation.
Adds cancelled count to DownloadStats and updates tracker.get_stats()
to populate it. This allows users to see how many downloads were
cancelled via manager.stats.cancelled.
Updates DownloadCancelledEvent to include:
- cancelled_from: CancelledFrom enum indicating if download was QUEUED or IN_PROGRESS

This allows subscribers to distinguish between cancelling queued vs active downloads.
@plutopulp plutopulp marked this pull request as ready for review December 16, 2025 14:18
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@plutopulp plutopulp merged commit e66bec4 into main Dec 16, 2025
5 checks passed
@plutopulp plutopulp deleted the cancel-by-id branch December 16, 2025 14:19
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