zcaudate-me / cronj

moved -> 'hara.io.scheduler'
http://docs.caudate.me/hara/hara-io-scheduler.html
107 stars 5 forks source link

Adding/removing tasks for started scheduler #13

Open gfrivolt opened 8 years ago

gfrivolt commented 8 years ago

Is there a possibility to add a task with a schedule for a started scheduler? I have two cases where this would be great to have:

Thank you for answer.

zcaudate commented 8 years ago

funny that you asked that =)

it was supported previously but I nerfed it because I wanted it to be more immutable. I’m pretty sure it’s possible to add it back again.

the function should still be there: https://github.com/zcaudate/cronj/blob/master/src/cronj/core.clj#L48-L52 https://github.com/zcaudate/cronj/blob/master/src/cronj/core.clj#L48-L52

Chris

On 21 Dec 2015, at 3:07 PM, György Frivolt notifications@github.com wrote:

Is there a possibility to add a task with a schedule for a started scheduler? I have two cases where this would be great to have:

the scheduler starts than other components can add their schedules, they would share the same one scheduler, otherwise probably I'd need to start up new scheduler for every case there are some delayed jobs which should be executed after several minutes or hours. These are executed only once. These are things like failed job retries. After the task is executed, it can be removed from the list of tasks Thank you for answer.

— Reply to this email directly or view it on GitHub https://github.com/zcaudate/cronj/issues/13.

gfrivolt commented 8 years ago

Great. I understand that it's good to have, where possible, things immutable.. but cronj scheduler is anyhow a changing structure. I see there are also other task list mutating functions like empty-tasks or unschedule-task so there are tools for task editing.

There is a {:pre [(tk/task? task)]} precondition, so the tasks must be running, otherwise they can not be added. But I see how simple it is to add a task to a scheduler. Is there any reason to keep that precondition?

Regarding immutability, maybe where now a "mutation" happened, a new scheduler would be returned referring to the previous scheduler.

zcaudate commented 8 years ago

Yep! I totally get where you are coming from. It's actually pretty easy I add a task and no, it does not have to be running :)