I’ve spent the last couple of days learning and understanding the new Coldbox Scheduler.
One of the first things I found is that when you call runEvent from the defined task, like:
task( "process-logs" )
.call( function(){
runEvent(event:"scheduled.station.processLogs", eventArguments:{"scheduled":true});
})
.every(5, "minutes")
.delay(1, "minutes")
.withNoOverlaps();
}
that runEvent does NOT fire interceptors. We toss a few things in the prc like prc.ServiceFactory and prc.Context (homegrown). I had to create a pre-handler in my “scheduled/station.cfc” to create those things for me. Kind of a duplicate of my SetupInterceptor. That’s okay, I didn’t mind too much, but I would suggest the documentation reflect that.
My second suggestion is this, in a round-about way. You can see I have an argument there. (Which I now know is a true arguments scoped variable!) I am creating the scheduled task that way so that I can also run it manually, if need be, and differentiate between a scheduled run and a manual hit-the-event-in-the-url execution.
You have that great .withNoOverlaps() feature. I think that’s pretty smart. I would say, though, it would be nice to have access to the information that must be stored somewhere indicating the task is running. If you have an “every minute” event that takes two minutes, the second execution must know it’s already in progress.
Yet, when I run this code:
local.oScheduler = controller.getSchedulerService().getSchedulers()[appScheduler@coldbox];|
local.stTask = local.oScheduler.getTaskRecord(arguments.task);|
The TaskRecord has no indication of whether its running or not. (It also, at least in my testing, does not show the “nextRun” time, it’s just blank in the dump.) But, again, it must be somewhere to prevent the overlaps and if it were included in the TaskRecord lookup… that would be cool.
It would be great for me to get that task that way, during my manual run, to determine if Coldbox is firing it right now, so I can NOT do a second run manually.
Just a couple of suggestions. But I really like it, and I’m glad I’m forcing myself to learn my way through it.