feat: add optional update_schedule method for ScheduleSource#519
feat: add optional update_schedule method for ScheduleSource#519danfimov wants to merge 1 commit intotaskiq-python:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an optional update_schedule method to the ScheduleSource abstract base class, enabling schedule sources to support updating existing schedules. This enhancement provides a standardized interface for modifying scheduled tasks, similar to the existing add_schedule and delete_schedule methods.
- Added
update_schedulemethod toScheduleSourceABC with comprehensive documentation - Implemented example usage in the schedule source documentation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| taskiq/abc/schedule_source.py | Added update_schedule method to the abstract base class with NotImplementedError for sources that don't support updates |
| docs/examples/extending/schedule_source.py | Added example implementation of update_schedule method demonstrating its usage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| # This method is optional. You may not implement this. | ||
| # It's just a helper to people to be able to interact with your source. | ||
| async def update_schedule(self, schedule: "ScheduledTask") -> None: |
There was a problem hiding this comment.
Why not just call delete and create in this method? Isn't it enough? Why do we need a separate method in each result_backend?
There was a problem hiding this comment.
It will be easier for library user to call one method instead of two. Like in this case for example: https://github.com/orgs/taskiq-python/discussions/535
And in postgres schedule source for example I will do delete + create in one transaction to not accidentally break something in case of connection error between two operations. Without this method user should think about it in his code and can even forget about it.
Added optional
update_schedulemethod forScheduleSource.This method will be simpler to use than delete and then recreate.