robfig / cron

a cron library for go
MIT License
13.16k stars 1.63k forks source link

how can i remove job when Cron is running? #5

Closed cgyy closed 9 years ago

cgyy commented 11 years ago

func (c *Cron) RemoveJob(identifier string) { //remove job by identifier }

i think add a method like this is useful

robfig commented 11 years ago

Hm, what would the identifier be?

cgyy commented 11 years ago

just like this, when a entry adde to cron, then generate a UUID or some randome string in the entry

robfig commented 11 years ago

That's a good idea. It could even just be an incrementing integer

elgs commented 10 years ago

Any update for the RemoveJob? I think the RemoveJob function will help cron to be really useful library for Golang.

ahall commented 10 years ago

+1

elgs commented 10 years ago

I have implemented RemoveFunc, PauseFunc and ResumeFunc and created pull request, waiting for @robfig to merge. But it's less likely to happen as this project seems to be less active in development now, though the code is very useful. Here are the links: https://github.com/elgs/cron https://github.com/robfig/cron/pull/15/files

ahall commented 10 years ago

Brilliang @eigs. I use this library in many projects to do all the scheduling of background tasks.

elgs commented 10 years ago

Thanks @ahall. This is totally awesome library. I hope robfig will consider to merge the RemoveFunc, PauseFunc and ResumeFunc to the code.

elgs commented 10 years ago

@ahall but be careful, if you use my code, the AddFunc returns a jobId int, and the error, as opposed to the original error, the jobId is the handler for you to reference the job instance when you want to Remove, Pause or Resume the job in the future. This actually has changed the AddFunc return values.

ahall commented 10 years ago

Thanks @elgs. Yes, what you're doing makes sense!

DAddYE commented 10 years ago

Any update on this? I need that too :(

robfig commented 9 years ago

This feature was added in https://github.com/robfig/cron/commit/2b666ea6e8456493a58c35ee494f95ebe1207f38

Please let me know if it does not meet your needs.

cgyy commented 9 years ago

Yes, thanks, It's a great job!

boernd commented 6 years ago

Is this feature just available in the v2 branch and no tagged versions?