cron
cron copied to clipboard
update cron schedule
Added a function Cron.UpdateSchedule(id, spec) that can be used to update the schedule of the cron job associated with the given id. The following changes/additions were made.
-
To allow for constant time lookup, added a new member to Cron. entryLookupTable map[EntryID]*Entry
-
Added a new function, addNewEntry(*Entry) that not only appends the entry to the list of entries but also adds it to the entryLookupTable.
-
Retrofitted Cron.Schedule() and Cron.run() to now use Cron.addNewEntry() instead of directly appending Cron.entries.
-
Retrofitted Cron.removeEntry() to also delete the entry from entryLookupTable.
Added test coverage for cron.UpdateSchedule(id, spec). The following tests were added.
- Update the schedule without calling cron.Start() and verify if the schedule interval changed.
- Update the schedule while the cron job is running (after calling cron.Start()) and verify if the schedule interval changed.
@robfig I have made the changes you requested.
@robfig - this is a gentle reminder for reviewing this PR :).
@robfig let me know if you would want me to update the documentation to include UpdateSchedule(...) usage in the README.
when people can use this method? ;)
Hi @robfig Can you take a look at the PR? Thanks.
Bump.
why don't merge to master?