nim-schedules icon indicating copy to clipboard operation
nim-schedules copied to clipboard

[Feature Request] Delay After instead of Delay Fixed

Open theAkito opened this issue 1 year ago • 0 comments

every(minutes=5, id="tick")

Currently, there is only an option for a fixed delay. That means, that if a process takes about 4 minutes, but the scheduler executes its tasks "every 5 minutes", then the task already gets executed 1 minute after the last one finished.

It would be helpful, if there were a bool flag, to indicate, that the scheduling count should start once the previous task finishes.

For example: delayAfter = true

Or, if one wants to really get fancy, one might implement an enum for options like these.

Example

type
  ScheduleOption* = enum
    delayAfter,
    delayFixed

Or, one could stay consistent with the current philosophy and add another scheduling type wrapped in macro.

https://github.com/soasme/nim-schedules/blob/ce1fe58ef7cc8a8670a8835031fcd5c5262083af/src/schedules/scheduler.nim#L454-L460

 proc processSchedule(call: NimNode): NimNode = 
   call.expectKind nnkCall 
   let cmdName = call[0].`$` 
   case cmdName 
   of "every": processEvery(call) 
   of "cron": processCron(call)
   of "everyAfter": processEveryAfter(call)
   else: raise newException(Exception, "unknown cmd: " & cmdName) 

Anyway, thank you for this great library! 😄

theAkito avatar Oct 25 '22 20:10 theAkito