jamesmh / coravel

Near-zero config .NET library that makes advanced application features like Task Scheduling, Caching, Queuing, Event Broadcasting, and more a breeze!
https://docs.coravel.net/Installation/
MIT License
3.87k stars 256 forks source link

Scheduling configuration from appsettings? #208

Open MihailsKuzmins opened 3 years ago

MihailsKuzmins commented 3 years ago

Describe the solution you'd like Currently Coravel supports configuration for "Mail" and "Queue", but not for "Scheduler" Configuration of IScheduler has a lot of handy extension methods in code, however, in order to configure scheduling dynamically (e.g. from appsettings.json), the only was is by passing a cron expression directly (please correct me if this statement is wrong), e.g. _scheduler.Cron("* * * * *"), so it means that a person who might be responsible for configuring a service must learn the patter behind the cron expression. While it's not an ordeal I think it would be nice to have something like this Serilog sample. Possible options could be like the ones in the windows Task Schedule configuration. P.S. I might also make an attempt to create a PR for it

Describe alternatives you've considered Using the cron expression :)

alexandercarls commented 3 years ago

I've been using Everyseconds(n) for a dynamic value.

However this does not work, due to an argument check as listed here: https://github.com/jamesmh/coravel/blob/751d1c39fad0f65b8201d30b64a3b25053818e6d/Src/Coravel/Scheduling/Schedule/Event/ScheduledEvent.cs#L335

I think that check can be removed, which would allow the library to schedule with dynamic values other than cron expressions.