|
199 | 199 | :.cron.add[func;args;`repeat;startTime;0Wp;interval];
|
200 | 200 | };
|
201 | 201 |
|
| 202 | +/ Schedules a job that repeats forever but only if there isn't an active job with the same function and arguments |
| 203 | +/ @param uFunc (Symbol) Symbol reference to the function to execute |
| 204 | +/ @param uArgs () Any arguments that are required to execute the function. Pass generic null (::) for no arguments |
| 205 | +/ @param startTime (Timestamp) The first time the job will be run |
| 206 | +/ @param interval (Timespan) The interval at which repeating jobs should recur. Pass null (0Nn) for one time jobs |
| 207 | +/ @returns (Long) The job ID either of the existing job, or the newly scheduled job |
| 208 | +/ @see .cron.addRepeatForeverJob |
| 209 | +.cron.addUniqueRepeatForeverJob:{[uFunc;uArgs;startTime;interval] |
| 210 | + match:exec from .cron.jobs where func = uFunc, args ~\: uArgs, not 0Wp = nextRunTime; |
| 211 | + |
| 212 | + if[not null match`id; |
| 213 | + .log.if.info ("Cron job with matching function and arguments is active. Not adding job [ Function: {} ] [ Arguments: {} ]"; uFunc; uArgs); |
| 214 | + :match`id; |
| 215 | + ]; |
| 216 | + |
| 217 | + :.cron.addRepeatForeverJob[uFunc; uArgs; startTime; interval]; |
| 218 | + }; |
| 219 | + |
202 | 220 | / Shortcut function to add a job that repeats until a specified time
|
203 | 221 | / @param func (Symbol) Symbol reference to the function to execute
|
204 | 222 | / @param args () Any arguments that are required to execute the function. Pass generic null (::) for no arguments
|
|
210 | 228 | :.cron.add[func;args;`repeat;startTime;endTime;interval];
|
211 | 229 | };
|
212 | 230 |
|
| 231 | +/ Schedules a job that repeats until the specified time but only if there isn't an active job with the same function and arguments |
| 232 | +/ @param uFunc (Symbol) Symbol reference to the function to execute |
| 233 | +/ @param uArgs () Any arguments that are required to execute the function. Pass generic null (::) for no arguments |
| 234 | +/ @param startTime (Timestamp) The first time the job will be run |
| 235 | +/ @param endTime (Timestamp) The time to finish a repeating job executing. Pass null (0Np) to repeat forever or for one time jobs |
| 236 | +/ @param interval (Timespan) The interval at which repeating jobs should recur. Pass null (0Nn) for one time jobs |
| 237 | +/ @see .cron.addRepeatUntilTimeJob |
| 238 | +.cron.addUniqueRepeatUntilTimeJob:{[uFunc;uArgs;startTime;endTime;interval] |
| 239 | + match:exec from .cron.jobs where func = uFunc, args ~\: uArgs, not 0Wp = nextRunTime; |
| 240 | + |
| 241 | + if[not null match`id; |
| 242 | + .log.if.info ("Cron job with matching function and arguments is active. Not adding job [ Function: {} ] [ Arguments: {} ]"; uFunc; uArgs); |
| 243 | + :match`id; |
| 244 | + ]; |
| 245 | + |
| 246 | + :.cron.addRepeatUntilTimeJob[uFunc; uArgs; startTime; endTime; interval]; |
| 247 | + }; |
| 248 | + |
213 | 249 | / Cancels the specified job from running. Run once jobs will never run and repeating jobs will no longer run
|
214 | 250 | / @param jobId (Long) The ID of the job to cancel
|
215 | 251 | / @throws InvalidCronJobException If the ID of the job does not exist
|
|
0 commit comments