Skip to content

Add CLI and programmatic utility to clear the docket#142

Merged
chrisguidry merged 6 commits intomainfrom
issue-119
Jun 20, 2025
Merged

Add CLI and programmatic utility to clear the docket#142
chrisguidry merged 6 commits intomainfrom
issue-119

Conversation

@chrisguidry
Copy link
Owner

@chrisguidry chrisguidry commented Jun 20, 2025

Summary

Closes #119 by adding both programmatic and CLI utilities to clear all pending and scheduled tasks from a docket.

  • Programmatic: New async clear() method on Docket class
  • CLI: New docket clear command accessible via CLI
  • Safe operation: Only removes pending/scheduled tasks, preserves running tasks and strikes
  • Proper cleanup: Removes all associated data (parked tasks, known task keys)
  • User feedback: Returns/displays count of cleared tasks

Implementation Details

  • Uses XTRIM with approximate=False to clear stream messages while preserving consumer groups
  • Deletes queue and associated Redis keys atomically using pipelines
  • Includes comprehensive test coverage for both programmatic and CLI usage
  • Handles edge cases like empty dockets, mixed task types, and strike preservation

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Jun 20, 2025

📚 Documentation has been built for this PR!

You can download the documentation directly here:
https://github.com/chrisguidry/docket/actions/runs/15769121322/artifacts/3366783818

chrisguidry and others added 2 commits June 19, 2025 20:55
## Summary
- Adds detailed development commands (testing, linting, type checking)
- Documents core architecture including Docket/Worker classes and
dependency injection system
- Explains Redis data model and task lifecycle
- Provides project structure overview and CLI usage examples

This expanded documentation will help future Claude Code instances work
more effectively in this codebase by understanding the distributed task
queue architecture and development workflow.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
Add pragma: no cover to Valkey-specific code paths that are not executed
in the default test environment. Also add --cov-fail-under=100 to CI
to ensure coverage regressions are caught automatically.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (79c4844) to head (fe7fa67).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              main      #142    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           27        28     +1     
  Lines         3358      3561   +203     
  Branches       190       191     +1     
==========================================
+ Hits          3358      3561   +203     
Flag Coverage Δ
python-3.12 100.00% <100.00%> (+0.02%) ⬆️
python-3.13 100.00% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/docket/cli.py 100.00% <100.00%> (ø)
src/docket/docket.py 100.00% <100.00%> (ø)
tests/cli/test_clear.py 100.00% <100.00%> (ø)
tests/conftest.py 100.00% <100.00%> (ø)
tests/test_docket.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

chrisguidry and others added 3 commits June 19, 2025 21:10
Ensures that docket.clear() properly cleans up all Redis keys without
leaking data structures by verifying key count before and after clearing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add type: ignore comments to handle Redis keys() method's partial
type information in pyright strict mode while preserving type safety
with cast annotations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@chrisguidry chrisguidry merged commit 819bfc9 into main Jun 20, 2025
16 checks passed
@chrisguidry chrisguidry deleted the issue-119 branch June 20, 2025 01:22
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.

CLI and programmatic utility to clear the docket

2 participants