Closed janrnc closed 1 year ago
I've dug a bit deeper into this.
FuncJob
is adapting func()
s to the Job
interface. Considering that cron just needs a generic code block to execute, a simple func()
should be enough IMO. Closures would help in more complex cases and in general the mapping between cron schedule IDs and the context of the job can be user's responsibility. This way extra complexity is introduced only when it's really necessary.
JobWrapper
and Chain
may probably be simplified too but I'd like to review those in some next refactor.
See #15
Do you think there's a good reason for having a
FuncJob
type definition forfunc()
? https://github.com/gdgvda/cron/blob/5eb0ef714f0dea726f412d4d57328ba2011f50ae/cron.go#L134It provides a
Run()
method which just calls itself. It feels like a simplefunc()
would do the same without additional wrapping. In this way alsoJobWrapper
could be removed, since we could get the same result by simply nesting function calls. https://github.com/gdgvda/cron/blob/5eb0ef714f0dea726f412d4d57328ba2011f50ae/chain.go#L11