coravel
coravel copied to clipboard
Schedule invocable at specific DateTime
I was looking into how I can schedule an invokable at a specific DateTime in the future, but I can't find an api for this except the
Cron(string cronExpression)
method.
The inconvenience of using this method is that it expects a specific cron formatted string. Is there an api to convert DateTime to cron expressions?
My use case for such a request is to schedule external API calls to refresh some expired passwords, knowing the DateTime when the passwords will be renewed by parsing the API response body.
No, that doesn't exist.
What you could do is create a database table, for example, store the date of when a particular API call + other needed data needs to be triggered.
Have an invocable scheduled for every minute/hour/whatever that will check that table. If the current time is after the time in any of those DB records, then do the API call for that record and remove the record upon success.
Something like that might work?
It doesn't seems that efficient to pool a database every minute. Instead I've create a PR to implement this https://github.com/jamesmh/coravel/pull/247