openfaas / cron-connector

Invoke functions on a schedule.
MIT License
39 stars 10 forks source link

[Feature Request] Add multiple schedules to a function #24

Closed kevin-lindsay-1 closed 2 years ago

kevin-lindsay-1 commented 2 years ago

My actions before raising this issue

When using cron, if you need to schedule a job at, say, every 90 minutes, you actually need two cron schedules to accomplish that.

To accommodate that, I think it would be fairly easy to make the schedule annotation a comma-separated list.

Expected Behaviour

To schedule a function to run every 90 minutes: schedule: "0 0-21/3 * * *,30 1-22/3 * * *". AFAIK the timezone is always UTC.

Current Behaviour

I don't think the cron connector supports multiple schedules for a single function.

Possible Solution

Comma separated list of schedules.

Steps to Reproduce (for bugs)

Context

I have a job that needs to wait 90 minutes between attempts.

Your Environment

Next steps

You may join Slack for community support.

derek[bot] commented 2 years ago

Please complete the whole issue template, without deleting any headings.

kevin-lindsay-1 commented 2 years ago

this is not a bug. i'm not sure what derek's complaining about here, because I didn't edit the template.

i'm not going to fill in bug report information just to appease this bot, because this is not a bug report.

kevin-lindsay-1 commented 2 years ago

I looked at the underlying cron library that this connector uses, and it looks like it supports @every <duration> schedules. Testing.

kevin-lindsay-1 commented 2 years ago

It looks like the @every syntax works. I'll reopen if I have any more problems.

alexellis commented 2 years ago

So was no change required in this instance?

alexellis commented 2 years ago

I've turned off that Derek feature :upside_down_face:

kevin-lindsay-1 commented 2 years ago

So was no change required in this instance?

it was not. the upstream cron scheduling package covers cases such as @every 1h30m. If you need precise scheduling of a function, such as every hour and a half at the 00 and 30 minute-marks, you'd need multiple schedules, though.

@every is based off when you started scheduling, so if you choose 1h30m, it will be 1h30m from when the schedule began. No way to choose specific times.