cron icon indicating copy to clipboard operation
cron copied to clipboard

update cron schedule

Open pradykaushik opened this issue 5 years ago • 8 comments

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.

  1. To allow for constant time lookup, added a new member to Cron. entryLookupTable map[EntryID]*Entry

  2. Added a new function, addNewEntry(*Entry) that not only appends the entry to the list of entries but also adds it to the entryLookupTable.

  3. Retrofitted Cron.Schedule() and Cron.run() to now use Cron.addNewEntry() instead of directly appending Cron.entries.

  4. Retrofitted Cron.removeEntry() to also delete the entry from entryLookupTable.

Added test coverage for cron.UpdateSchedule(id, spec). The following tests were added.

  1. Update the schedule without calling cron.Start() and verify if the schedule interval changed.
  2. Update the schedule while the cron job is running (after calling cron.Start()) and verify if the schedule interval changed.

pradykaushik avatar Jan 05 '20 01:01 pradykaushik

@robfig I have made the changes you requested.

pradykaushik avatar Jan 17 '20 22:01 pradykaushik

@robfig - this is a gentle reminder for reviewing this PR :).

pradykaushik avatar Feb 05 '20 01:02 pradykaushik

@robfig let me know if you would want me to update the documentation to include UpdateSchedule(...) usage in the README.

pradykaushik avatar Mar 30 '20 02:03 pradykaushik

when people can use this method? ;)

mghifariyusuf avatar May 13 '20 08:05 mghifariyusuf

Hi @robfig Can you take a look at the PR? Thanks.

ahmagdy avatar May 22 '20 21:05 ahmagdy

Bump.

l0010o0001l avatar Oct 12 '20 01:10 l0010o0001l

why don't merge to master?

phpmaple avatar Nov 16 '20 09:11 phpmaple